DonateSupplies as Enter subclass

This commit is contained in:
atlimit8
2014-10-04 19:07:41 -05:00
parent 41452dcfeb
commit c994ee4668
2 changed files with 12 additions and 17 deletions

View File

@@ -13,33 +13,28 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
class DonateSupplies : Activity
class DonateSupplies : Enter
{
Target target;
int payload;
readonly Actor target;
readonly int payload;
public DonateSupplies(Actor target, int payload)
public DonateSupplies(Actor self, Actor target, int payload)
: base(self, target)
{
this.target = Target.FromActor(target);
this.target = target;
this.payload = payload;
}
public override Activity Tick(Actor self)
protected override void OnInside(Actor self)
{
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
if (target.IsDead())
return;
if (target.Type != TargetType.Actor)
return NextActivity;
var targetActor = target.Actor;
targetActor.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
self.Destroy();
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
self.World.AddFrameEndTask(w => w.Add(new FloatingText(targetActor.CenterPosition, targetActor.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
return this;
self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
}
}
}

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA
self.CancelActivity();
self.SetTargetLine(target, Color.Yellow);
self.QueueActivity(new Enter(self, target.Actor, new DonateSupplies(target.Actor, info.Payload)));
self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload));
}
class SupplyTruckOrderTargeter : UnitOrderTargeter