Drafted Vision blocking functionality and respective MapRef->HelperFunctions
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Algo/Reverse.h"
|
||||
#include "Util/IndexPriorityQueue.h"
|
||||
#include <cmath.h>
|
||||
|
||||
// Sets default values
|
||||
AAdventureMap::AAdventureMap()
|
||||
@@ -83,6 +84,36 @@ AHexTile* AAdventureMap::RandomHex()
|
||||
return Grid[RandHex];
|
||||
}
|
||||
|
||||
FHexVector AAdventureMap::AxialRound(float qf, float rf)
|
||||
{
|
||||
float sf = -qf - rf;
|
||||
|
||||
int32 q = round(qf);
|
||||
int32 r = round(rf);
|
||||
int32 s = round(sf);
|
||||
|
||||
float q_diff = abs(q - qf);
|
||||
float r_diff = abs(r - rf);
|
||||
float s_diff = abs(s - sf);
|
||||
|
||||
if (q_diff > r_diff && q_diff > s_diff)
|
||||
{ q = -r - s; }
|
||||
else if (r_diff > s_diff)
|
||||
{ r = -q - s; }
|
||||
else
|
||||
{ s = -q - r; }
|
||||
|
||||
return FHexVector(q, r);
|
||||
}
|
||||
|
||||
float AAdventureMap::Lerp(int32 a, int32 b, int32 t)
|
||||
{
|
||||
return float(a + (b - a) * t);
|
||||
}
|
||||
// FHexVector SampleHex = MapRef->AxialRound(Lerpl(a, b, t), Lerp(x, y, z));
|
||||
//
|
||||
|
||||
|
||||
TArray<AHexTile*> AAdventureMap::Neighbors(AHexTile* OfHex, bool bFreeOnly = false)
|
||||
{
|
||||
TArray<AHexTile*> Results;
|
||||
@@ -143,6 +174,8 @@ TSet<AHexTile*> AAdventureMap::BreadthFirstSearch(AHexTile* Start, int32 Radius)
|
||||
return Results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* // Faulty implementation which uses an actual PriorityQueue
|
||||
TArray<AHexTile*> AAdventureMap::FindPathAStar(AHexTile* Start, AHexTile* Goal, bool bDiags)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user