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:
reaperrr
2016-09-29 21:26:07 +02:00
parent 6571f926fb
commit 9cf916e8b6

View File

@@ -115,11 +115,15 @@ namespace OpenRA.Mods.Common.Traits
public int TurnSpeed { get { return Info.TurnSpeed; } }
public Actor ReservedActor { get; private set; }
public bool MayYieldReservation { get; private set; }
public bool IsMovingVertically { get; private set; }
bool airborne;
bool cruising;
bool firstTick = true;
bool isMoving;
WPos cachedPosition;
public Aircraft(ActorInitializer init, AircraftInfo info)
{
Info = info;
@@ -142,6 +146,7 @@ namespace OpenRA.Mods.Common.Traits
{
um = self.TraitOrDefault<UpgradeManager>();
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
cachedPosition = self.CenterPosition;
}
public void AddedToWorld(Actor self)
@@ -174,6 +179,11 @@ namespace OpenRA.Mods.Common.Traits
self.QueueActivity(new TakeOff(self));
}
var oldCachedPosition = cachedPosition;
cachedPosition = self.CenterPosition;
isMoving = (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0;
IsMovingVertically = (oldCachedPosition - cachedPosition).VerticalLengthSquared != 0;
Repulse();
}
@@ -483,7 +493,7 @@ namespace OpenRA.Mods.Common.Traits
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)
{