Add a ReturnToGroundLayerOnIdle flag to CustomMovementLayers
Co-authored-by: Mazar Farran <farranmazar@gmail.com> Co-authored-by: Paul Chote <paul@chote.net>
This commit is contained in:
committed by
reaperrr
parent
8fc483b30b
commit
0bd00d3b7c
@@ -672,7 +672,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyBecomingIdle.OnBecomingIdle(Actor self)
|
||||
{
|
||||
if (TopLeft.Layer == 0)
|
||||
if (self.Location.Layer == 0)
|
||||
return;
|
||||
|
||||
var cml = self.World.WorldActor.TraitsImplementing<ICustomMovementLayer>()
|
||||
.First(l => l.Index == self.Location.Layer);
|
||||
|
||||
if (!cml.ReturnToGroundLayerOnIdle)
|
||||
return;
|
||||
|
||||
var moveTo = ClosestGroundCell();
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return enabled; }
|
||||
byte ICustomMovementLayer.Index { get { return CustomMovementLayerType.ElevatedBridge; } }
|
||||
bool ICustomMovementLayer.InteractsWithDefaultLayer { get { return true; } }
|
||||
bool ICustomMovementLayer.ReturnToGroundLayerOnIdle { get { return false; } }
|
||||
|
||||
WPos ICustomMovementLayer.CenterOfCell(CPos cell)
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return li is JumpjetLocomotorInfo; }
|
||||
byte ICustomMovementLayer.Index { get { return CustomMovementLayerType.Jumpjet; } }
|
||||
bool ICustomMovementLayer.InteractsWithDefaultLayer { get { return true; } }
|
||||
bool ICustomMovementLayer.ReturnToGroundLayerOnIdle { get { return true; } }
|
||||
|
||||
WPos ICustomMovementLayer.CenterOfCell(CPos cell)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return EmptyPath;
|
||||
|
||||
var distance = source - target;
|
||||
if (distance.LengthSquared < 3 && li.CanMoveFreelyInto(world, self, target, null, CellConditions.All))
|
||||
if (source.Layer == target.Layer && distance.LengthSquared < 3 && li.CanMoveFreelyInto(world, self, target, null, CellConditions.All))
|
||||
return new List<CPos> { target };
|
||||
|
||||
List<CPos> pb;
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return li is SubterraneanLocomotorInfo; }
|
||||
byte ICustomMovementLayer.Index { get { return CustomMovementLayerType.Subterranean; } }
|
||||
bool ICustomMovementLayer.InteractsWithDefaultLayer { get { return false; } }
|
||||
bool ICustomMovementLayer.ReturnToGroundLayerOnIdle { get { return true; } }
|
||||
|
||||
WPos ICustomMovementLayer.CenterOfCell(CPos cell)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return enabled; }
|
||||
byte ICustomMovementLayer.Index { get { return CustomMovementLayerType.Tunnel; } }
|
||||
bool ICustomMovementLayer.InteractsWithDefaultLayer { get { return false; } }
|
||||
bool ICustomMovementLayer.ReturnToGroundLayerOnIdle { get { return true; } }
|
||||
|
||||
WPos ICustomMovementLayer.CenterOfCell(CPos cell)
|
||||
{
|
||||
|
||||
@@ -367,6 +367,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
byte Index { get; }
|
||||
bool InteractsWithDefaultLayer { get; }
|
||||
bool ReturnToGroundLayerOnIdle { get; }
|
||||
|
||||
bool EnabledForActor(ActorInfo a, LocomotorInfo li);
|
||||
int EntryMovementCost(ActorInfo a, LocomotorInfo li, CPos cell);
|
||||
|
||||
Reference in New Issue
Block a user