Set Mobile.IsMoving to "true" if queueing a turn that takes only a single tick
At the end of L-turns, actors often end up with an internal facing not 100% matching the direction of the next cell on their path. As a result, if they haven't reached their destination yet, Move queues a quick Turn as ChildActivity, which previously was not considered as IsMoving. However, we don't want those mini-turns to interrupt move animations, so we now consider them a move as well. Additionally, to avoid any issues, we make these mini-turns non-interruptible, just like the MovePart activities already are.
This commit is contained in:
@@ -19,14 +19,27 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly IDisabledTrait disablable;
|
||||
readonly IFacing facing;
|
||||
readonly Mobile mobile;
|
||||
readonly int desiredFacing;
|
||||
readonly bool setIsMoving;
|
||||
|
||||
public Turn(Actor self, int desiredFacing, bool isInterruptible = true)
|
||||
public Turn(Actor self, int desiredFacing, bool setIsMoving = false, bool isInterruptible = true)
|
||||
{
|
||||
disablable = self.TraitOrDefault<IMove>() as IDisabledTrait;
|
||||
facing = self.Trait<IFacing>();
|
||||
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)
|
||||
@@ -44,5 +57,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
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 (mobile != null && mobile.IsMoving)
|
||||
mobile.IsMoving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user