Files
OpenRA/OpenRa.Game/Traits/Activities/Steal.cs
2010-01-17 09:30:53 +13:00

28 lines
638 B
C#

namespace OpenRa.Traits.Activities
{
class Steal : IActivity
{
Actor target;
public Steal(Actor target) { this.target = target; }
public IActivity NextActivity { get; set; }
public IActivity Tick(Actor self)
{
if (target == null || target.IsDead) return NextActivity;
if (target.Owner == self.Owner) return NextActivity;
foreach (var t in target.traits.WithInterface<IAcceptThief>())
t.OnSteal(target, self);
Game.world.AddFrameEndTask(w => w.Remove(self));
return NextActivity;
}
public void Cancel(Actor self) { target = null; NextActivity = null; }
}
}