Neighbors function draft; refactoring
This commit is contained in:
parent
b5c9c661fe
commit
219b99c8d7
@ -20,7 +20,7 @@ AAdventureCameraPawn::AAdventureCameraPawn()
|
||||
|
||||
ESASize = .01;
|
||||
BaseScrollSpeed = 16;
|
||||
ScrollAccelleration = BaseScrollSpeed * 2.2;
|
||||
ScrollAccelleration = BaseScrollSpeed * 2.4;
|
||||
|
||||
ESAMaxBoundSlope = 1 / (1 - (1-ESASize));
|
||||
ESAMaxBoundIntercept = 1 - ESAMaxBoundSlope;
|
||||
|
@ -34,10 +34,9 @@ void AAdventureCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInput
|
||||
|
||||
}
|
||||
|
||||
void AAdventureCharacter::AStarFindPath(AHexTile*)
|
||||
void AAdventureCharacter::AStarFindPath(AHexTile* Goal)
|
||||
{
|
||||
std::priority_queue<int32> Frontier;
|
||||
TMap<AHexTile*, AHexTile*> CameFrom;
|
||||
TMap<AHexTile*, int32> CostSoFar;
|
||||
|
||||
}
|
@ -92,3 +92,29 @@ AHexTile* AAdventureMap::RandomHex()
|
||||
}
|
||||
return Grid[RandHex];
|
||||
}
|
||||
|
||||
TArray<AHexTile*> AAdventureMap::Neighbors(AHexTile* OfHex)
|
||||
{
|
||||
TArray<AHexTile*> Neighbors;
|
||||
int32 Index;
|
||||
|
||||
Index = GridIndex(OfHex->Q + 1 , OfHex->R + 0 );
|
||||
if (Index < Grid.Num() && Index >= 0) { Neighbors.Add(Grid[Index]); }
|
||||
|
||||
Index = GridIndex(OfHex->Q + 1 , OfHex->R - 1 );
|
||||
if (Index < Grid.Num() && Index >= 0) { Neighbors.Add(Grid[Index]); }
|
||||
|
||||
Index = GridIndex(OfHex->Q + 0 , OfHex->R - 1 );
|
||||
if (Index < Grid.Num() && Index >= 0) { Neighbors.Add(Grid[Index]); }
|
||||
|
||||
Index = GridIndex(OfHex->Q - 1 , OfHex->R + 0 );
|
||||
if (Index < Grid.Num() && Index >= 0) { Neighbors.Add(Grid[Index]); }
|
||||
|
||||
Index = GridIndex(OfHex->Q - 1 , OfHex->R + 1 );
|
||||
if (Index < Grid.Num() && Index >= 0) { Neighbors.Add(Grid[Index]); }
|
||||
|
||||
Index = GridIndex(OfHex->Q + 0 , OfHex->R + 1 );
|
||||
if (Index < Grid.Num() && Index >= 0) { Neighbors.Add(Grid[Index]); }
|
||||
|
||||
return Neighbors; // currently wrapping from corner to corner --> rectify this with a manhattan distance check
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
int32 GridIndex(int32 q, int32 r);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
AHexTile* RandomHex();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<AHexTile*> Neighbors(AHexTile* OfHexTile);
|
||||
|
||||
// Player spawn section
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "HexTile.h"
|
||||
#include "AdventurePlayerController.h"
|
||||
|
||||
#include "AdventureMap.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
|
||||
// Sets default values
|
||||
@ -39,9 +39,3 @@ void AHexTile::FillCornersArray()
|
||||
Corners.Emplace(Corner(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
TArray<AHexTile*> AHexTile::Neighbors(AHexTile* OfHexTile)
|
||||
{
|
||||
return TArray<AHexTile*>();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
class USceneComponent;
|
||||
class UStaticMeshComponent;
|
||||
|
||||
class AAdventureMap;
|
||||
class AAdventurePlayerController;
|
||||
|
||||
UCLASS()
|
||||
@ -40,9 +40,8 @@ public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Runtime")
|
||||
int32 Index;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
TArray<AHexTile*> Neighbors(AHexTile* OfHexTile);
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Runtime")
|
||||
AAdventureMap* MapRef;
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
Loading…
Reference in New Issue
Block a user