Fix moves being reported as blocked when already at the destination.
When a move is made where the source and target locations are the same and no actual moving is required, a path of length 0 is returned. When a move cannot be made as there is no valid route, a path of length 0 is also returned. This means Move is unable to tell the difference between no movement required, and no path is possible. Currently it will hit the `hadNoPath` case and report CompleteDestinationBlocked. To fix the scenario where the source and target location match, track a alreadyAtDestination field. When this scenario triggers, report CompleteDestinationReached instead. This fixes activities that were using this result to inform their next actions. e.g. MoveOntoAndTurn would previously cancel the Turn portion of the activity, believing that the destination could not be reached. Now, it knows the destination was reached (since we are already there!) and will perform the turn.
This commit is contained in:
@@ -48,8 +48,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|| !Mobile.CanInteractWithGroundLayer(self) || !Mobile.CanStayInCell(self.Location));
|
||||
}
|
||||
|
||||
protected override List<CPos> CalculatePathToTarget(Actor self, BlockedByActor check)
|
||||
protected override (bool AlreadyAtDestination, List<CPos> Path) CalculatePathToTarget(Actor self, BlockedByActor check)
|
||||
{
|
||||
if (lastVisibleTargetLocation == self.Location)
|
||||
return (true, PathFinder.NoPath);
|
||||
|
||||
// PERF: Assume that candidate cells don't change within a tick to avoid repeated queries
|
||||
// when Move enumerates different BlockedByActor values.
|
||||
if (searchCellsTick != self.World.WorldTick)
|
||||
@@ -62,9 +65,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
if (SearchCells.Count == 0)
|
||||
return PathFinder.NoPath;
|
||||
return (false, PathFinder.NoPath);
|
||||
|
||||
return Mobile.PathFinder.FindPathToTargetCells(self, self.Location, SearchCells, check);
|
||||
return (false, Mobile.PathFinder.FindPathToTargetCells(self, self.Location, SearchCells, check));
|
||||
}
|
||||
|
||||
bool AtCorrectRange(WPos origin)
|
||||
|
||||
Reference in New Issue
Block a user