Add plumbing for notifying traits of movement
More precisely, about start and stop of movement.
This commit is contained in:
@@ -19,7 +19,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public class Drag : Activity
|
||||
{
|
||||
readonly IPositionable positionable;
|
||||
readonly IMove movement;
|
||||
readonly IDisabledTrait disableable;
|
||||
WPos start, end;
|
||||
int length;
|
||||
@@ -28,8 +27,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Drag(Actor self, WPos start, WPos end, int length)
|
||||
{
|
||||
positionable = self.Trait<IPositionable>();
|
||||
movement = self.TraitOrDefault<IMove>();
|
||||
disableable = movement as IDisabledTrait;
|
||||
disableable = self.TraitOrDefault<IMove>() as IDisabledTrait;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.length = length;
|
||||
@@ -47,15 +45,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
positionable.SetVisualPosition(self, pos);
|
||||
if (++ticks >= length)
|
||||
{
|
||||
if (movement != null)
|
||||
movement.IsMoving = false;
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
if (movement != null)
|
||||
movement.IsMoving = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -188,18 +188,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
path.Add(nextCell.Value.First);
|
||||
|
||||
// If Mobile.Info.AlwaysConsiderTurnAsMove is true, we consider Turn as movement regardless of facing delta size.
|
||||
// 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);
|
||||
QueueChild(self, new Turn(self, firstFacing), true);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -337,7 +326,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return this;
|
||||
|
||||
var ret = InnerTick(self, Move.mobile);
|
||||
Move.mobile.IsMoving = ret is MovePart;
|
||||
|
||||
if (moveFraction > MoveFractionTotal)
|
||||
moveFraction = MoveFractionTotal;
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
targetStartPos = target.Positions.PositionClosestTo(self.CenterPosition);
|
||||
mobile.IsMoving = true;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -84,11 +83,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return this;
|
||||
}
|
||||
|
||||
protected override void OnLastRun(Actor self)
|
||||
{
|
||||
mobile.IsMoving = false;
|
||||
}
|
||||
|
||||
public override IEnumerable<Target> GetTargets(Actor self)
|
||||
{
|
||||
yield return target;
|
||||
|
||||
Reference in New Issue
Block a user