Add plumbing for notifying traits of movement
More precisely, about start and stop of movement.
This commit is contained in:
@@ -94,8 +94,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
// We are at the destination
|
// We are at the destination
|
||||||
if (++ticks >= length)
|
if (++ticks >= length)
|
||||||
{
|
{
|
||||||
mobile.IsMoving = false;
|
|
||||||
|
|
||||||
// Revoke the run condition
|
// Revoke the run condition
|
||||||
attack.IsAiming = false;
|
attack.IsAiming = false;
|
||||||
|
|
||||||
@@ -113,8 +111,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
mobile.IsMoving = true;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
|
|
||||||
public bool ShouldBeOpen()
|
public bool ShouldBeOpen()
|
||||||
{
|
{
|
||||||
if (move.IsMoving || self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length > 0)
|
if (move.CurrentMovementTypes.HasFlag(MovementType.Horizontal) || self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c)
|
return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c)
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (movement.IsMoving)
|
if (movement.CurrentMovementTypes.HasFlag(MovementType.Horizontal)
|
||||||
|
|| movement.CurrentMovementTypes.HasFlag(MovementType.Turn))
|
||||||
tick++;
|
tick++;
|
||||||
|
|
||||||
if (tick < info.TickRate)
|
if (tick < info.TickRate)
|
||||||
|
|||||||
@@ -201,9 +201,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||||
|
|
||||||
// Actors with TDGunboat always move
|
// Actors with TDGunboat always move
|
||||||
public bool IsMoving { get { return true; } set { } }
|
public MovementType CurrentMovementTypes { get { return MovementType.Horizontal; } set { } }
|
||||||
|
|
||||||
public bool IsMovingVertically { get { return false; } set { } }
|
|
||||||
|
|
||||||
public bool CanEnterTargetNow(Actor self, Target target)
|
public bool CanEnterTargetNow(Actor self, Target target)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public class Drag : Activity
|
public class Drag : Activity
|
||||||
{
|
{
|
||||||
readonly IPositionable positionable;
|
readonly IPositionable positionable;
|
||||||
readonly IMove movement;
|
|
||||||
readonly IDisabledTrait disableable;
|
readonly IDisabledTrait disableable;
|
||||||
WPos start, end;
|
WPos start, end;
|
||||||
int length;
|
int length;
|
||||||
@@ -28,8 +27,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public Drag(Actor self, WPos start, WPos end, int length)
|
public Drag(Actor self, WPos start, WPos end, int length)
|
||||||
{
|
{
|
||||||
positionable = self.Trait<IPositionable>();
|
positionable = self.Trait<IPositionable>();
|
||||||
movement = self.TraitOrDefault<IMove>();
|
disableable = self.TraitOrDefault<IMove>() as IDisabledTrait;
|
||||||
disableable = movement as IDisabledTrait;
|
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
@@ -47,15 +45,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
positionable.SetVisualPosition(self, pos);
|
positionable.SetVisualPosition(self, pos);
|
||||||
if (++ticks >= length)
|
if (++ticks >= length)
|
||||||
{
|
|
||||||
if (movement != null)
|
|
||||||
movement.IsMoving = false;
|
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
|
||||||
|
|
||||||
if (movement != null)
|
|
||||||
movement.IsMoving = true;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,18 +188,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
path.Add(nextCell.Value.First);
|
path.Add(nextCell.Value.First);
|
||||||
|
|
||||||
// If Mobile.Info.AlwaysConsiderTurnAsMove is true, we consider Turn as movement regardless of facing delta size.
|
QueueChild(self, new Turn(self, firstFacing), true);
|
||||||
// IsMoving is then set back to false in Turn.OnLastRun.
|
|
||||||
// This is needed for actors that want to display their movement animation during turns (walker units, for example).
|
|
||||||
mobile.IsMoving = mobile.Info.AlwaysConsiderTurnAsMove;
|
|
||||||
|
|
||||||
// HACK: To fix visual hiccups on actors with move animations during "L-turn to next part of movement" transitions
|
|
||||||
// or invisible mini-turns (due to less sprite facings than internal facings), we set IsMoving to 'true' during Turn activity
|
|
||||||
// when the facing delta is low enough to be covered with a single Turn tick.
|
|
||||||
// To avoid issues, we also make these mini-turns uninterruptible (like MovePart activities) to ensure the actor
|
|
||||||
// finishes that mini-turn before starting something else.
|
|
||||||
var facingWithinTolerance = Util.FacingWithinTolerance(mobile.Facing, firstFacing, mobile.TurnSpeed);
|
|
||||||
QueueChild(self, new Turn(self, firstFacing, facingWithinTolerance, !facingWithinTolerance), true);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +326,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return this;
|
return this;
|
||||||
|
|
||||||
var ret = InnerTick(self, Move.mobile);
|
var ret = InnerTick(self, Move.mobile);
|
||||||
Move.mobile.IsMoving = ret is MovePart;
|
|
||||||
|
|
||||||
if (moveFraction > MoveFractionTotal)
|
if (moveFraction > MoveFractionTotal)
|
||||||
moveFraction = MoveFractionTotal;
|
moveFraction = MoveFractionTotal;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
targetStartPos = target.Positions.PositionClosestTo(self.CenterPosition);
|
targetStartPos = target.Positions.PositionClosestTo(self.CenterPosition);
|
||||||
mobile.IsMoving = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -84,11 +83,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLastRun(Actor self)
|
|
||||||
{
|
|
||||||
mobile.IsMoving = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<Target> GetTargets(Actor self)
|
public override IEnumerable<Target> GetTargets(Actor self)
|
||||||
{
|
{
|
||||||
yield return target;
|
yield return target;
|
||||||
|
|||||||
@@ -19,32 +19,18 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
readonly IDisabledTrait disablable;
|
readonly IDisabledTrait disablable;
|
||||||
readonly IFacing facing;
|
readonly IFacing facing;
|
||||||
readonly Mobile mobile;
|
|
||||||
readonly int desiredFacing;
|
readonly int desiredFacing;
|
||||||
readonly bool setIsMoving;
|
|
||||||
|
|
||||||
public Turn(Actor self, int desiredFacing, bool setIsMoving = false, bool isInterruptible = true)
|
public Turn(Actor self, int desiredFacing)
|
||||||
{
|
{
|
||||||
disablable = self.TraitOrDefault<IMove>() as IDisabledTrait;
|
disablable = self.TraitOrDefault<IMove>() as IDisabledTrait;
|
||||||
facing = self.Trait<IFacing>();
|
facing = self.Trait<IFacing>();
|
||||||
this.desiredFacing = desiredFacing;
|
this.desiredFacing = desiredFacing;
|
||||||
this.setIsMoving = setIsMoving;
|
|
||||||
IsInterruptible = isInterruptible;
|
|
||||||
|
|
||||||
// This might look confusing, but the current implementation of Mobile is both IMove and IDisabledTrait,
|
|
||||||
// and this way we can save a separate Mobile trait look-up.
|
|
||||||
mobile = disablable as Mobile;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnFirstRun(Actor self)
|
|
||||||
{
|
|
||||||
if (setIsMoving && mobile != null && !mobile.IsMoving)
|
|
||||||
mobile.IsMoving = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsInterruptible && IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
if (disablable != null && disablable.IsTraitDisabled)
|
if (disablable != null && disablable.IsTraitDisabled)
|
||||||
@@ -57,12 +43,5 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLastRun(Actor self)
|
|
||||||
{
|
|
||||||
// If Mobile.IsMoving was set to 'true' earlier, we want to reset it to 'false' before the next tick.
|
|
||||||
if (setIsMoving && mobile != null && mobile.IsMoving)
|
|
||||||
mobile.IsMoving = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
ConditionManager conditionManager;
|
ConditionManager conditionManager;
|
||||||
IDisposable reservation;
|
IDisposable reservation;
|
||||||
IEnumerable<int> speedModifiers;
|
IEnumerable<int> speedModifiers;
|
||||||
|
INotifyMoving[] notifyMoving;
|
||||||
|
|
||||||
[Sync] public int Facing { get; set; }
|
[Sync] public int Facing { get; set; }
|
||||||
[Sync] public WPos CenterPosition { get; private set; }
|
[Sync] public WPos CenterPosition { get; private set; }
|
||||||
@@ -191,9 +192,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
int airborneToken = ConditionManager.InvalidConditionToken;
|
int airborneToken = ConditionManager.InvalidConditionToken;
|
||||||
int cruisingToken = ConditionManager.InvalidConditionToken;
|
int cruisingToken = ConditionManager.InvalidConditionToken;
|
||||||
|
|
||||||
bool isMoving;
|
MovementType movementTypes;
|
||||||
bool isMovingVertically;
|
|
||||||
WPos cachedPosition;
|
WPos cachedPosition;
|
||||||
|
int cachedFacing;
|
||||||
bool? landNow;
|
bool? landNow;
|
||||||
|
|
||||||
public Aircraft(ActorInitializer init, AircraftInfo info)
|
public Aircraft(ActorInitializer init, AircraftInfo info)
|
||||||
@@ -233,6 +234,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
|
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
|
||||||
cachedPosition = self.CenterPosition;
|
cachedPosition = self.CenterPosition;
|
||||||
|
notifyMoving = self.TraitsImplementing<INotifyMoving>().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
@@ -317,10 +319,23 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldCachedFacing = cachedFacing;
|
||||||
|
cachedFacing = Facing;
|
||||||
|
|
||||||
var oldCachedPosition = cachedPosition;
|
var oldCachedPosition = cachedPosition;
|
||||||
cachedPosition = self.CenterPosition;
|
cachedPosition = self.CenterPosition;
|
||||||
isMoving = (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0;
|
|
||||||
isMovingVertically = (oldCachedPosition - cachedPosition).VerticalLengthSquared != 0;
|
var newMovementTypes = MovementType.None;
|
||||||
|
if (oldCachedFacing != Facing)
|
||||||
|
newMovementTypes |= MovementType.Turn;
|
||||||
|
|
||||||
|
if ((oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0)
|
||||||
|
newMovementTypes |= MovementType.Horizontal;
|
||||||
|
|
||||||
|
if ((oldCachedPosition - cachedPosition).VerticalLengthSquared != 0)
|
||||||
|
newMovementTypes |= MovementType.Vertical;
|
||||||
|
|
||||||
|
CurrentMovementTypes = newMovementTypes;
|
||||||
|
|
||||||
Repulse();
|
Repulse();
|
||||||
}
|
}
|
||||||
@@ -712,9 +727,22 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||||
|
|
||||||
public bool IsMoving { get { return isMoving; } set { } }
|
public MovementType CurrentMovementTypes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return movementTypes;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsMovingVertically { get { return isMovingVertically; } set { } }
|
set
|
||||||
|
{
|
||||||
|
var oldValue = movementTypes;
|
||||||
|
movementTypes = value;
|
||||||
|
if (value != oldValue)
|
||||||
|
foreach (var n in notifyMoving)
|
||||||
|
n.MovementTypeChanged(self, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanEnterTargetNow(Actor self, Target target)
|
public bool CanEnterTargetNow(Actor self, Target target)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (conditionManager == null)
|
if (conditionManager == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var isMovingVertically = Info.ConsiderVerticalMovement ? movement.IsMovingVertically : false;
|
var isMovingVertically = Info.ConsiderVerticalMovement ? movement.CurrentMovementTypes.HasFlag(MovementType.Vertical);
|
||||||
var isMoving = !IsTraitDisabled && !self.IsDead && (movement.IsMoving || isMovingVertically);
|
var isMoving = !IsTraitDisabled && !self.IsDead && (movement.CurrentMovementTypes.HasFlag(MovementType.Horizontal) || isMovingVertically);
|
||||||
if (isMoving && conditionToken == ConditionManager.InvalidConditionToken)
|
if (isMoving && conditionToken == ConditionManager.InvalidConditionToken)
|
||||||
conditionToken = conditionManager.GrantCondition(self, Info.Condition);
|
conditionToken = conditionManager.GrantCondition(self, Info.Condition);
|
||||||
else if (!isMoving && conditionToken != ConditionManager.InvalidConditionToken)
|
else if (!isMoving && conditionToken != ConditionManager.InvalidConditionToken)
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Speed at which the actor turns.")]
|
[Desc("Speed at which the actor turns.")]
|
||||||
public readonly int TurnSpeed = 255;
|
public readonly int TurnSpeed = 255;
|
||||||
|
|
||||||
[Desc("Should turning always be considering as moving (instead of only turning while moving forward).")]
|
|
||||||
public readonly bool AlwaysConsiderTurnAsMove = false;
|
|
||||||
|
|
||||||
public readonly int Speed = 1;
|
public readonly int Speed = 1;
|
||||||
|
|
||||||
public readonly string Cursor = "move";
|
public readonly string Cursor = "move";
|
||||||
@@ -124,22 +121,39 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Mobile : PausableConditionalTrait<MobileInfo>, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove,
|
public class Mobile : PausableConditionalTrait<MobileInfo>, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, ITick,
|
||||||
IFacing, IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier, INotifyBecomingIdle
|
IFacing, IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier, INotifyBecomingIdle
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly Lazy<IEnumerable<int>> speedModifiers;
|
readonly Lazy<IEnumerable<int>> speedModifiers;
|
||||||
|
|
||||||
#region IMove IsMoving checks
|
#region IMove CurrentMovementTypes
|
||||||
public bool IsMoving { get; set; }
|
MovementType movementTypes;
|
||||||
public bool IsMovingVertically { get { return false; } set { } }
|
public MovementType CurrentMovementTypes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return movementTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var oldValue = movementTypes;
|
||||||
|
movementTypes = value;
|
||||||
|
if (value != oldValue)
|
||||||
|
foreach (var n in notifyMoving)
|
||||||
|
n.MovementTypeChanged(self, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
int facing;
|
int oldFacing, facing;
|
||||||
|
WPos oldPos;
|
||||||
CPos fromCell, toCell;
|
CPos fromCell, toCell;
|
||||||
public SubCell FromSubCell, ToSubCell;
|
public SubCell FromSubCell, ToSubCell;
|
||||||
INotifyCustomLayerChanged[] notifyCustomLayerChanged;
|
INotifyCustomLayerChanged[] notifyCustomLayerChanged;
|
||||||
INotifyVisualPositionChanged[] notifyVisualPositionChanged;
|
INotifyVisualPositionChanged[] notifyVisualPositionChanged;
|
||||||
|
INotifyMoving[] notifyMoving;
|
||||||
INotifyFinishedMoving[] notifyFinishedMoving;
|
INotifyFinishedMoving[] notifyFinishedMoving;
|
||||||
|
|
||||||
#region IFacing
|
#region IFacing
|
||||||
@@ -201,11 +215,27 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
notifyCustomLayerChanged = self.TraitsImplementing<INotifyCustomLayerChanged>().ToArray();
|
notifyCustomLayerChanged = self.TraitsImplementing<INotifyCustomLayerChanged>().ToArray();
|
||||||
notifyVisualPositionChanged = self.TraitsImplementing<INotifyVisualPositionChanged>().ToArray();
|
notifyVisualPositionChanged = self.TraitsImplementing<INotifyVisualPositionChanged>().ToArray();
|
||||||
|
notifyMoving = self.TraitsImplementing<INotifyMoving>().ToArray();
|
||||||
notifyFinishedMoving = self.TraitsImplementing<INotifyFinishedMoving>().ToArray();
|
notifyFinishedMoving = self.TraitsImplementing<INotifyFinishedMoving>().ToArray();
|
||||||
|
|
||||||
base.Created(self);
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ITick.Tick(Actor self)
|
||||||
|
{
|
||||||
|
var newMovementTypes = MovementType.None;
|
||||||
|
if (oldPos != CenterPosition)
|
||||||
|
newMovementTypes |= MovementType.Horizontal;
|
||||||
|
|
||||||
|
if (oldFacing != Facing)
|
||||||
|
newMovementTypes |= MovementType.Turn;
|
||||||
|
|
||||||
|
CurrentMovementTypes = newMovementTypes;
|
||||||
|
|
||||||
|
oldPos = CenterPosition;
|
||||||
|
oldFacing = Facing;
|
||||||
|
}
|
||||||
|
|
||||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.AddToMaps(self, this);
|
self.World.AddToMaps(self, this);
|
||||||
|
|||||||
@@ -140,12 +140,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
wasModifying = rsm.IsModifyingSequence;
|
wasModifying = rsm.IsModifyingSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((state != AnimationState.Moving || dirty) && move.IsMoving)
|
if ((state != AnimationState.Moving || dirty) && move.CurrentMovementTypes.HasFlag(MovementType.Horizontal))
|
||||||
{
|
{
|
||||||
state = AnimationState.Moving;
|
state = AnimationState.Moving;
|
||||||
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, Info.MoveSequence));
|
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, Info.MoveSequence));
|
||||||
}
|
}
|
||||||
else if (((state == AnimationState.Moving || dirty) && !move.IsMoving)
|
else if (((state == AnimationState.Moving || dirty) && !move.CurrentMovementTypes.HasFlag(MovementType.Horizontal))
|
||||||
|| ((state == AnimationState.Idle || state == AnimationState.IdleAnimating) && !self.IsIdle))
|
|| ((state == AnimationState.Idle || state == AnimationState.IdleAnimating) && !self.IsIdle))
|
||||||
PlayStandAnimation(self);
|
PlayStandAnimation(self);
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
if (IsTraitDisabled || wsb.IsTraitDisabled)
|
if (IsTraitDisabled || wsb.IsTraitDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var isMoving = movement.IsMoving && !self.IsDead;
|
var isMoving = movement.CurrentMovementTypes.HasFlag(MovementType.Horizontal) && !self.IsDead;
|
||||||
|
|
||||||
if (isMoving ^ (wsb.DefaultAnimation.CurrentSequence.Name != Info.MoveSequence))
|
if (isMoving ^ (wsb.DefaultAnimation.CurrentSequence.Name != Info.MoveSequence))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
static bool IsMovingInMyDirection(Actor self, Actor other)
|
static bool IsMovingInMyDirection(Actor self, Actor other)
|
||||||
{
|
{
|
||||||
var otherMobile = other.TraitOrDefault<Mobile>();
|
var otherMobile = other.TraitOrDefault<Mobile>();
|
||||||
if (otherMobile == null || !otherMobile.IsMoving)
|
if (otherMobile == null || !otherMobile.CurrentMovementTypes.HasFlag(MovementType.Horizontal))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var selfMobile = self.TraitOrDefault<Mobile>();
|
var selfMobile = self.TraitOrDefault<Mobile>();
|
||||||
|
|||||||
@@ -410,8 +410,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
||||||
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
|
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
|
||||||
CPos NearestMoveableCell(CPos target);
|
CPos NearestMoveableCell(CPos target);
|
||||||
bool IsMoving { get; set; }
|
MovementType CurrentMovementTypes { get; set; }
|
||||||
bool IsMovingVertically { get; set; }
|
|
||||||
bool CanEnterTargetNow(Actor self, Target target);
|
bool CanEnterTargetNow(Actor self, Target target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,4 +547,19 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
bool PreventMapSpawn(World world, ActorReference actorReference);
|
bool PreventMapSpawn(World world, ActorReference actorReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum MovementType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Horizontal = 1,
|
||||||
|
Vertical = 2,
|
||||||
|
Turn = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
[RequireExplicitImplementation]
|
||||||
|
public interface INotifyMoving
|
||||||
|
{
|
||||||
|
void MovementTypeChanged(Actor self, MovementType type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user