Change Aircraft.IsMoving to only return true when moving horizontally
Additionally added IsMovingVertically for potential edge cases where vertical movement needs to be considered.
This commit is contained in:
@@ -115,11 +115,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public int TurnSpeed { get { return Info.TurnSpeed; } }
|
public int TurnSpeed { get { return Info.TurnSpeed; } }
|
||||||
public Actor ReservedActor { get; private set; }
|
public Actor ReservedActor { get; private set; }
|
||||||
public bool MayYieldReservation { get; private set; }
|
public bool MayYieldReservation { get; private set; }
|
||||||
|
public bool IsMovingVertically { get; private set; }
|
||||||
|
|
||||||
bool airborne;
|
bool airborne;
|
||||||
bool cruising;
|
bool cruising;
|
||||||
bool firstTick = true;
|
bool firstTick = true;
|
||||||
|
|
||||||
|
bool isMoving;
|
||||||
|
WPos cachedPosition;
|
||||||
|
|
||||||
public Aircraft(ActorInitializer init, AircraftInfo info)
|
public Aircraft(ActorInitializer init, AircraftInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
@@ -142,6 +146,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
um = self.TraitOrDefault<UpgradeManager>();
|
um = self.TraitOrDefault<UpgradeManager>();
|
||||||
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
|
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
|
||||||
|
cachedPosition = self.CenterPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
public void AddedToWorld(Actor self)
|
||||||
@@ -174,6 +179,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(new TakeOff(self));
|
self.QueueActivity(new TakeOff(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldCachedPosition = cachedPosition;
|
||||||
|
cachedPosition = self.CenterPosition;
|
||||||
|
isMoving = (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0;
|
||||||
|
IsMovingVertically = (oldCachedPosition - cachedPosition).VerticalLengthSquared != 0;
|
||||||
|
|
||||||
Repulse();
|
Repulse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +493,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||||
|
|
||||||
public bool IsMoving { get { return self.World.Map.DistanceAboveTerrain(CenterPosition).Length > 0; } set { } }
|
public bool IsMoving { get { return isMoving; } set { } }
|
||||||
|
|
||||||
public bool CanEnterTargetNow(Actor self, Target target)
|
public bool CanEnterTargetNow(Actor self, Target target)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user