Use named pathfinding constants.

- Rename CostForInvalidCell to PathCostForInvalidPath
- Add MovementCostForUnreachableCell
- Update usages of int.MaxValue and short.Maxvalue to use named constants where relevant.
- Update costs on ICustomMovementLayer to return short, for consistency with costs from Locomotor.
- Rename some methods to distinguish between path/movement cost.
This commit is contained in:
RoosterDragon
2021-10-08 20:35:33 +01:00
committed by abcdefg30
parent 884e6cdb51
commit df9398a871
16 changed files with 57 additions and 54 deletions

View File

@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
locomotor = world.WorldActor.TraitsImplementing<Locomotor>()
.SingleOrDefault(l => l.Info.Name == Locomotor);
if (locomotor.MovementCostForCell(cell) == short.MaxValue)
if (locomotor.MovementCostForCell(cell) == PathGraph.MovementCostForUnreachableCell)
return false;
return locomotor.CanMoveFreelyInto(self, cell, subCell, check, ignoreActor);
@@ -520,7 +520,7 @@ namespace OpenRA.Mods.Common.Traits
public bool CanExistInCell(CPos cell)
{
return Locomotor.MovementCostForCell(cell) != short.MaxValue;
return Locomotor.MovementCostForCell(cell) != PathGraph.MovementCostForUnreachableCell;
}
public bool CanEnterCell(CPos cell, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
@@ -1020,7 +1020,7 @@ namespace OpenRA.Mods.Common.Traits
if (mobile.IsTraitPaused
|| !self.World.Map.Contains(location)
|| (!explored && !locomotorInfo.MoveIntoShroud)
|| (explored && mobile.Locomotor.MovementCostForCell(location) == short.MaxValue))
|| (explored && mobile.Locomotor.MovementCostForCell(location) == PathGraph.MovementCostForUnreachableCell))
cursor = mobile.Info.BlockedCursor;
else if (!explored || !mobile.Info.TerrainCursors.TryGetValue(self.World.Map.GetTerrainInfo(location).Type, out cursor))
cursor = mobile.Info.Cursor;