implemented diagonal movement
This commit is contained in:
+50
-36
@@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Containers/Map.h"
|
||||
#include "HexVector.h"
|
||||
#include "AdventureMap.generated.h"
|
||||
|
||||
class AHexTile;
|
||||
@@ -20,16 +21,14 @@ public:
|
||||
// Sets default values for this actor's properties
|
||||
AAdventureMap();
|
||||
|
||||
UPROPERTY()
|
||||
UWorld* World;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
TSubclassOf<AHexTile> BaseTileClass;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
TSubclassOf<ACharacter> BasePartyCharacterClass;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
int32 GridSize = 100; // squared is the number of Tiles
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
int32 TileSize = 100;
|
||||
UPROPERTY()
|
||||
UWorld* World;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Generation")
|
||||
void MakeGrid();
|
||||
@@ -38,43 +37,58 @@ public:
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Generation")
|
||||
TArray<AHexTile*> Grid;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Utility")
|
||||
int32 GridIndex(int32 q, int32 r);
|
||||
UFUNCTION(BlueprintCallable, Category = "Utility")
|
||||
AHexTile* RandomHex();
|
||||
|
||||
// Cardinal direction vectors
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag
|
||||
FHexVector N = FHexVector(1, -2);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FHexVector NNE = FHexVector(1, -1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag
|
||||
FHexVector ENE = FHexVector(2, -1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FHexVector E = FHexVector(1, 0);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag
|
||||
FHexVector ESE = FHexVector(1, 1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FHexVector SSE = FHexVector(0, 1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag
|
||||
FHexVector S = FHexVector(-1, 2);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FHexVector SSW = FHexVector(-1, 1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag
|
||||
FHexVector WSW = FHexVector(-2, 1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FHexVector W = FHexVector(-1, 0);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere) //diag
|
||||
FHexVector WNW = FHexVector(-1, -1);
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FHexVector NNW = FHexVector(0, -1);
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
TArray<FHexVector> NeighborUnitVectors;
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
TArray<FHexVector> DiagonalUnitVectors;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> Neighbors(AHexTile* OfHex, bool bFreeOnly);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> FreeDiags(AHexTile* OfHex);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TSet<AHexTile*> BreadthFirstSearch(AHexTile* Start, int32 Radius);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> FindPathAStar(AHexTile* Start, AHexTile* Goal, bool bDiags);
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
TMap<AHexTile*, AMapObject*> MapObjects;
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
TMap<int32, AMapObject*> MapObjectsByID;
|
||||
int32 IncID = -1;
|
||||
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
|
||||
int32 IncID = -1;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
int32 GridIndex(int32 q, int32 r);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
AHexTile* RandomHex();
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> Neighbors(AHexTile* OfHex);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> Diagonals(AHexTile* OfHex);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> BreadthFirstSearch(AHexTile* Start, int32 Radius);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> AStar(AHexTile* Start, AHexTile* Goal);
|
||||
UFUNCTION(BlueprintCallable, Category = "Runtime")
|
||||
TArray<AHexTile*> LinkPath(AHexTile* Start, AHexTile* Goal);
|
||||
|
||||
// Cardinal direction vectors
|
||||
TPair<int32, int32> N = TPair<int32,int32>(1, -2); //diag
|
||||
TPair<int32, int32> NNE = TPair<int32,int32>(1, -1);
|
||||
TPair<int32, int32> ENE = TPair<int32,int32>(2, -1); //diag
|
||||
TPair<int32, int32> E = TPair<int32,int32>(1, 0);
|
||||
TPair<int32, int32> ESE = TPair<int32,int32>(1, 1); //diag
|
||||
TPair<int32, int32> SSE = TPair<int32,int32>(0, 1);
|
||||
TPair<int32, int32> S = TPair<int32,int32>(-1, 2); //diag
|
||||
TPair<int32, int32> SSW = TPair<int32,int32>(-1, 1);
|
||||
TPair<int32, int32> WSW = TPair<int32,int32>(-2, 1); //diag
|
||||
TPair<int32, int32> W = TPair<int32,int32>(-1, 0);
|
||||
TPair<int32, int32> WNW = TPair<int32,int32>(-1, -1); //diag
|
||||
TPair<int32, int32> NNW = TPair<int32,int32>(0, -1);
|
||||
|
||||
TArray<TPair<int32, int32>> NBVectors;
|
||||
TArray<TPair<int32, int32>> NBVectorsDiag;
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
|
||||
Reference in New Issue
Block a user