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

@@ -85,16 +85,16 @@ namespace OpenRA.Mods.Common.Traits
return map.Ramp[cell] == 0;
}
int ICustomMovementLayer.EntryMovementCost(LocomotorInfo li, CPos cell)
short ICustomMovementLayer.EntryMovementCost(LocomotorInfo li, CPos cell)
{
var sli = (SubterraneanLocomotorInfo)li;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.CostForInvalidCell;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.MovementCostForUnreachableCell;
}
int ICustomMovementLayer.ExitMovementCost(LocomotorInfo li, CPos cell)
short ICustomMovementLayer.ExitMovementCost(LocomotorInfo li, CPos cell)
{
var sli = (SubterraneanLocomotorInfo)li;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.CostForInvalidCell;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.MovementCostForUnreachableCell;
}
byte ICustomMovementLayer.GetTerrainIndex(CPos cell)