Merge pull request #12129 from reaperrr/aircraft-ismoving

Change Aircraft.IsMoving to be true only when moving horizontally
This commit is contained in:
Paul Chote
2016-10-15 15:07:41 +01:00
committed by GitHub
4 changed files with 21 additions and 15 deletions

View File

@@ -27,24 +27,16 @@ namespace OpenRA.Mods.Common.Traits.Render
readonly IMove movement;
readonly WithSpriteBody wsb;
WPos cachedPosition;
public WithMoveAnimation(ActorInitializer init, WithMoveAnimationInfo info)
{
this.info = info;
movement = init.Self.Trait<IMove>();
wsb = init.Self.Trait<WithSpriteBody>();
cachedPosition = init.Self.CenterPosition;
}
public void Tick(Actor self)
{
var oldCachedPosition = cachedPosition;
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;
var isMoving = movement.IsMoving && !self.IsDead;
if (isMoving ^ (wsb.DefaultAnimation.CurrentSequence.Name != info.MoveSequence))
return;