Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 55277f9

Browse files
committed
add ConsiderGenerateTile()
1 parent e349586 commit 55277f9

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Source/Navgrid/Classes/GridPawn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class NAVGRID_API AGridPawn : public APawn, public IGenericTeamAgentInterface
118118
template <class T>
119119
T *GetTile() const { return Cast<T>(GetTile()); }
120120

121-
/* Return current tile, if this is NULL consider generating a virtual tile at our feet and returing that*/
121+
/* Place a tile under our feet if there is not alrady one there. Returne the tile under our feet */
122122
UNavTileComponent *ConsiderGenerateVirtualTile();
123123
template <class T>
124124
T *ConsiderGenerateVirtualTile() { return Cast<T>(ConsiderGenerateVirtualTile()); }

Source/Navgrid/Classes/NavGrid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ class NAVGRID_API ANavGrid : public AActor
135135
/* place a single virtual tile under a pawn */
136136
UFUNCTION(BlueprintCallable, Category = "Pathfinding")
137137
void GenerateVirtualTile(const AGridPawn *Pawn);
138+
UNavTileComponent *ConsiderGenerateVirtualTile(const FVector &TileLocation);
138139
void DestroyVirtualTiles();
139140
virtual void Destroyed() override;
140-
141141
public:
142142
/** return every tile in the supplied world */
143143
static void GetEveryTile(TArray<UNavTileComponent* > &OutTiles, UWorld *World);

Source/Navgrid/Private/GridPawn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ UNavTileComponent *AGridPawn::ConsiderGenerateVirtualTile()
228228
{
229229
if (!IsValid(MovementComponent->GetTile()) && MovementComponent->GetNavGrid()->EnableVirtualTiles)
230230
{
231-
GenerateVirtualTiles();
231+
return MovementComponent->GetNavGrid()->ConsiderGenerateVirtualTile(GetActorLocation());
232232
}
233233
return MovementComponent->GetTile();
234234
}

Source/Navgrid/Private/NavGrid.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,16 @@ void ANavGrid::GenerateVirtualTile(const AGridPawn * Pawn)
405405
}
406406
}
407407

408+
UNavTileComponent * ANavGrid::ConsiderGenerateVirtualTile(const FVector & TileLocation)
409+
{
410+
UNavTileComponent *TileComp = ConsiderPlaceTile(TileLocation + FVector(0, 0, TileSize), TileLocation - FVector(0, 0, TileSize));
411+
if (TileComp)
412+
{
413+
VirtualTiles.Add(TileComp);
414+
}
415+
return TileComp;
416+
}
417+
408418
void ANavGrid::DestroyVirtualTiles()
409419
{
410420
for (UNavTileComponent *T : VirtualTiles)

0 commit comments

Comments
 (0)