small changes & cleanup

This commit is contained in:
2022-01-29 20:54:35 +01:00
parent 2bf072e3c6
commit 429ce51805
7 changed files with 32 additions and 67 deletions
+5 -11
View File
@@ -60,31 +60,25 @@ TArray<AHexTile*> AAdventurePlayerController::Vision()
void AAdventurePlayerController::TogglePlacing()
{
bInPlacementMode = !bInPlacementMode;
if (bInPlacementMode) {
PlaceObj = World->SpawnActor<AMapObject>(PlaceObjClass, FTransform());
}
if (bInPlacementMode) { PlaceObj = World->SpawnActor<AMapObject>(PlaceObjClass, FTransform()); }
else { if (IsValid(PlaceObj)) { PlaceObj->Destroy(); } }
}
void AAdventurePlayerController::FitOnGrid(AMapObject* MapObject)
{
if (!IsValid(HoveredHex)) { return; }
if (HoveredHex->bFree) {
MapObject->SetActorLocation(FVector(HoveredHex->GetActorLocation()));
}
if (HoveredHex->bFree) { MapObject->SetActorLocation(FVector(HoveredHex->GetActorLocation())); }
}
// called from BP; generally takes the Hex under the player cursor as argument
void AAdventurePlayerController::PlaceObject(TSubclassOf<AMapObject> MapObjClass, AHexTile* OnHex)
{
// spawn this Actor at World location of Origin Hex;
AMapObject* SpawnedObj = World->SpawnActor<AMapObject>(MapObjClass, FTransform(OnHex->GetActorTransform().GetLocation()));
SpawnedObj->Origin = OnHex;
OnHex->bFree = false;
SpawnedObj->Occupy();
// set Hexes to bOccupied according to BlockVectors;
OnHex->bFree = false; // exact Hexes are eventually to be determined by MapObjectClass's BlockingVectors
MapRef->MapObjects.Add(OnHex, SpawnedObj); // maybe this as well
MapRef->MapObjects.Add(OnHex, SpawnedObj);
MapRef->IncID++;
SpawnedObj->ID = MapRef->IncID;
MapRef->MapObjectsByID.Add(MapRef->IncID, SpawnedObj);