Split Locomotor trait from Mobile
Add GrantConditionOn*Layer traits This allows to - drop some booleans from Locomotor - drop a good part of the subterranean- and jumpjet-specific code/hacks from Mobile - grant more than 1 condition per layer type (via multiple traits) - easily add more traits of this kind for other layers
This commit is contained in:
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, MobileInfo mi) { return mi.Subterranean; }
|
||||
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return li is SubterraneanLocomotorInfo; }
|
||||
byte ICustomMovementLayer.Index { get { return CustomMovementLayerType.Subterranean; } }
|
||||
bool ICustomMovementLayer.InteractsWithDefaultLayer { get { return false; } }
|
||||
|
||||
@@ -71,13 +71,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return pos + new WVec(0, 0, height[cell] - pos.Z);
|
||||
}
|
||||
|
||||
bool ValidTransitionCell(CPos cell, MobileInfo mi)
|
||||
bool ValidTransitionCell(CPos cell, LocomotorInfo li)
|
||||
{
|
||||
var terrainType = map.GetTerrainInfo(cell).Type;
|
||||
if (!mi.SubterraneanTransitionTerrainTypes.Contains(terrainType) && mi.SubterraneanTransitionTerrainTypes.Any())
|
||||
var sli = (SubterraneanLocomotorInfo)li;
|
||||
if (!sli.SubterraneanTransitionTerrainTypes.Contains(terrainType) && sli.SubterraneanTransitionTerrainTypes.Any())
|
||||
return false;
|
||||
|
||||
if (mi.SubterraneanTransitionOnRamps)
|
||||
if (sli.SubterraneanTransitionOnRamps)
|
||||
return true;
|
||||
|
||||
var tile = map.Tiles[cell];
|
||||
@@ -85,14 +86,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return ti == null || ti.RampType == 0;
|
||||
}
|
||||
|
||||
int ICustomMovementLayer.EntryMovementCost(ActorInfo a, MobileInfo mi, CPos cell)
|
||||
int ICustomMovementLayer.EntryMovementCost(ActorInfo a, LocomotorInfo li, CPos cell)
|
||||
{
|
||||
return ValidTransitionCell(cell, mi) ? mi.SubterraneanTransitionCost : int.MaxValue;
|
||||
var sli = (SubterraneanLocomotorInfo)li;
|
||||
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : int.MaxValue;
|
||||
}
|
||||
|
||||
int ICustomMovementLayer.ExitMovementCost(ActorInfo a, MobileInfo mi, CPos cell)
|
||||
int ICustomMovementLayer.ExitMovementCost(ActorInfo a, LocomotorInfo li, CPos cell)
|
||||
{
|
||||
return ValidTransitionCell(cell, mi) ? mi.SubterraneanTransitionCost : int.MaxValue;
|
||||
var sli = (SubterraneanLocomotorInfo)li;
|
||||
return ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : int.MaxValue;
|
||||
}
|
||||
|
||||
byte ICustomMovementLayer.GetTerrainIndex(CPos cell)
|
||||
|
||||
Reference in New Issue
Block a user