Update ICustomMovementLayer to not depend on actor for costs.

No implementations require the actor.
This commit is contained in:
RoosterDragon
2021-09-25 14:28:00 +01:00
committed by Paul Chote
parent 6f3b4ecae9
commit 3a020e96fe
6 changed files with 30 additions and 26 deletions

View File

@@ -10,6 +10,7 @@
#endregion
using System.Linq;
using OpenRA.Mods.Common.Pathfinder;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -61,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return li is SubterraneanLocomotorInfo; }
bool ICustomMovementLayer.EnabledForLocomotor(LocomotorInfo li) { return li is SubterraneanLocomotorInfo; }
byte ICustomMovementLayer.Index => CustomMovementLayerType.Subterranean;
bool ICustomMovementLayer.InteractsWithDefaultLayer => false;
bool ICustomMovementLayer.ReturnToGroundLayerOnIdle => true;
@@ -84,16 +85,16 @@ namespace OpenRA.Mods.Common.Traits
return map.Ramp[cell] == 0;
}
int ICustomMovementLayer.EntryMovementCost(ActorInfo a, LocomotorInfo li, CPos cell)
int ICustomMovementLayer.EntryMovementCost(LocomotorInfo li, CPos cell)
{
var sli = (SubterraneanLocomotorInfo)li;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : int.MaxValue;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.CostForInvalidCell;
}
int ICustomMovementLayer.ExitMovementCost(ActorInfo a, LocomotorInfo li, CPos cell)
int ICustomMovementLayer.ExitMovementCost(LocomotorInfo li, CPos cell)
{
var sli = (SubterraneanLocomotorInfo)li;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : int.MaxValue;
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.CostForInvalidCell;
}
byte ICustomMovementLayer.GetTerrainIndex(CPos cell)