Merge pull request #12129 from reaperrr/aircraft-ismoving
Change Aircraft.IsMoving to be true only when moving horizontally
This commit is contained in:
@@ -308,6 +308,7 @@ namespace OpenRA.Traits
|
|||||||
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
||||||
CPos NearestMoveableCell(CPos target);
|
CPos NearestMoveableCell(CPos target);
|
||||||
bool IsMoving { get; set; }
|
bool IsMoving { get; set; }
|
||||||
|
bool IsMovingVertically { get; set; }
|
||||||
bool CanEnterTargetNow(Actor self, Target target);
|
bool CanEnterTargetNow(Actor self, Target target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool airborne;
|
bool airborne;
|
||||||
bool cruising;
|
bool cruising;
|
||||||
|
bool firstTick = true;
|
||||||
|
|
||||||
|
bool isMoving;
|
||||||
|
bool isMovingVertically;
|
||||||
|
WPos cachedPosition;
|
||||||
|
|
||||||
public Aircraft(ActorInitializer init, AircraftInfo info)
|
public Aircraft(ActorInitializer init, AircraftInfo info)
|
||||||
{
|
{
|
||||||
@@ -141,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)
|
||||||
@@ -154,7 +160,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
OnCruisingAltitudeReached();
|
OnCruisingAltitudeReached();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool firstTick = true;
|
|
||||||
public virtual void Tick(Actor self)
|
public virtual void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (firstTick)
|
if (firstTick)
|
||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,12 +276,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected void ReserveSpawnBuilding()
|
protected void ReserveSpawnBuilding()
|
||||||
{
|
{
|
||||||
/* HACK: not spawning in the air, so try to assoc. with our afld. */
|
// HACK: Not spawning in the air, so try to associate with our spawner.
|
||||||
var afld = GetActorBelow();
|
var spawner = GetActorBelow();
|
||||||
if (afld == null)
|
if (spawner == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MakeReservation(afld);
|
MakeReservation(spawner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeReservation(Actor target)
|
public void MakeReservation(Actor target)
|
||||||
@@ -483,7 +493,9 @@ 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 IsMovingVertically { get { return isMovingVertically; } set { } }
|
||||||
|
|
||||||
public bool CanEnterTargetNow(Actor self, Target target)
|
public bool CanEnterTargetNow(Actor self, Target target)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly Lazy<IEnumerable<int>> speedModifiers;
|
readonly Lazy<IEnumerable<int>> speedModifiers;
|
||||||
public bool IsMoving { get; set; }
|
public bool IsMoving { get; set; }
|
||||||
|
public bool IsMovingVertically { get { return false; } set { } }
|
||||||
|
|
||||||
int facing;
|
int facing;
|
||||||
CPos fromCell, toCell;
|
CPos fromCell, toCell;
|
||||||
|
|||||||
@@ -27,24 +27,16 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
readonly IMove movement;
|
readonly IMove movement;
|
||||||
readonly WithSpriteBody wsb;
|
readonly WithSpriteBody wsb;
|
||||||
|
|
||||||
WPos cachedPosition;
|
|
||||||
|
|
||||||
public WithMoveAnimation(ActorInitializer init, WithMoveAnimationInfo info)
|
public WithMoveAnimation(ActorInitializer init, WithMoveAnimationInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
movement = init.Self.Trait<IMove>();
|
movement = init.Self.Trait<IMove>();
|
||||||
wsb = init.Self.Trait<WithSpriteBody>();
|
wsb = init.Self.Trait<WithSpriteBody>();
|
||||||
|
|
||||||
cachedPosition = init.Self.CenterPosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var oldCachedPosition = cachedPosition;
|
var isMoving = movement.IsMoving && !self.IsDead;
|
||||||
cachedPosition = self.CenterPosition;
|
|
||||||
|
|
||||||
// Flying units set IsMoving whenever they are airborne, which isn't enough for our purposes
|
|
||||||
var isMoving = movement.IsMoving && !self.IsDead && (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0;
|
|
||||||
if (isMoving ^ (wsb.DefaultAnimation.CurrentSequence.Name != info.MoveSequence))
|
if (isMoving ^ (wsb.DefaultAnimation.CurrentSequence.Name != info.MoveSequence))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user