Add plumbing for notifying traits of movement

More precisely, about start and stop of movement.
This commit is contained in:
reaperrr
2018-08-26 13:49:23 +02:00
committed by Paul Chote
parent 32ab822786
commit a10af382b4
15 changed files with 102 additions and 84 deletions

View File

@@ -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;
}