MovementArrow functionality; StarFog implemented; Refactoring
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "AdventureCameraPawn.h"
|
||||
#include "AdventureCharacter.h"
|
||||
#include "MapObject.h"
|
||||
#include "MovementArrow.h"
|
||||
|
||||
|
||||
|
||||
AAdventurePlayerController::AAdventurePlayerController()
|
||||
@@ -19,7 +21,9 @@ void AAdventurePlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
World = GetWorld();
|
||||
|
||||
HoveredHex = CurrentHex;
|
||||
|
||||
}
|
||||
// Called every frame
|
||||
void AAdventurePlayerController::Tick(float DeltaTime)
|
||||
@@ -36,13 +40,19 @@ void AAdventurePlayerController::SetupInputComponent()
|
||||
|
||||
// This is initialized on startup, you can go straight to binding
|
||||
InputComponent->BindAction("LeftClick", IE_Pressed, this, &AAdventurePlayerController::LeftClick);
|
||||
InputComponent->BindAction("DebugAlt", IE_Pressed, this, &AAdventurePlayerController::TogglePlacing); // Change binding eventually
|
||||
InputComponent->BindAction("DebugAlt", IE_Pressed, this, &AAdventurePlayerController::EnablePlacing); // Change binding eventually
|
||||
InputComponent->BindAction("DebugAlt", IE_Released, this, &AAdventurePlayerController::DisablePlacing); // Change binding eventually
|
||||
}
|
||||
|
||||
void AAdventurePlayerController::LeftClick()
|
||||
{
|
||||
if (!IsValid(HoveredHex)) { return; }
|
||||
if (bInPlacementMode) { PlaceObject(PlaceObjClass, HoveredHex); }
|
||||
if (IsValid(HoveredHex)) {
|
||||
if (!bInPlacementMode) {
|
||||
|
||||
}
|
||||
else { PlaceObject(PlaceObjClass, HoveredHex); }
|
||||
}
|
||||
else { return; }
|
||||
}
|
||||
|
||||
TArray<AHexTile*> AAdventurePlayerController::Vision(int32 Radius)
|
||||
@@ -59,11 +69,38 @@ TArray<AHexTile*> AAdventurePlayerController::Vision(int32 Radius)
|
||||
return Results;
|
||||
}
|
||||
|
||||
void AAdventurePlayerController::TogglePlacing()
|
||||
void AAdventurePlayerController::MarkPath(TArray<AHexTile*> Path)
|
||||
{
|
||||
bInPlacementMode = !bInPlacementMode;
|
||||
if (bInPlacementMode) { PlaceObj = World->SpawnActor<AMapObject>(PlaceObjClass, FTransform()); }
|
||||
else { if (IsValid(PlaceObj)) { PlaceObj->Destroy(); } }
|
||||
FHexVector DirA = FHexVector(Path[0]->Q - CurrentHex->Q, Path[0]->R - CurrentHex->R);
|
||||
FHexVector DirB;
|
||||
for (int32 i = 0; i < Path.Num() - 1; i++)
|
||||
{
|
||||
DirB = FHexVector(Path[i + 1]->Q - Path[i]->Q, Path[i + 1]->R - Path[i]->R);
|
||||
AMovementArrow* Arrow = World->SpawnActor<AMovementArrow>(MoveArrowClass, Path[i]->GetActorTransform());
|
||||
Arrow->MapRef = MapRef;
|
||||
Arrow->SetVariant(DirA, DirB);
|
||||
PathArrows.Add(Arrow);
|
||||
DirA = DirB;
|
||||
}
|
||||
}
|
||||
void AAdventurePlayerController::ClearPath()
|
||||
{
|
||||
for (AMovementArrow* Arrow : PathArrows) {
|
||||
Arrow->Destroy();
|
||||
}
|
||||
PathArrows.Empty();
|
||||
}
|
||||
|
||||
void AAdventurePlayerController::EnablePlacing()
|
||||
{
|
||||
bInPlacementMode = true;
|
||||
PlaceObj = World->SpawnActor<AMapObject>(PlaceObjClass, FTransform());
|
||||
}
|
||||
|
||||
void AAdventurePlayerController::DisablePlacing()
|
||||
{
|
||||
bInPlacementMode = false;
|
||||
// if (IsValid(PlaceObj)) { PlaceObj->Destroy(); }
|
||||
}
|
||||
|
||||
void AAdventurePlayerController::FitOnGrid(AMapObject* MapObject)
|
||||
|
||||
Reference in New Issue
Block a user