Files
OpenRA/OpenRa.Mods.RA/Crate Actions/GiveCashCrateAction.cs
2010-02-11 15:15:53 +13:00

37 lines
825 B
C#

using OpenRa.Mods.RA.Effects;
using OpenRa.Traits;
namespace OpenRa.Mods.RA
{
class GiveCashCrateActionInfo : ITraitInfo
{
public int Amount = 2000;
public int SelectionShares = 10;
public object Create(Actor self) { return new GiveCashCrateAction(self); }
}
class GiveCashCrateAction : ICrateAction
{
Actor self;
public GiveCashCrateAction(Actor self)
{
this.self = self;
}
public int SelectionShares
{
get { return self.Info.Traits.Get<GiveCashCrateActionInfo>().SelectionShares; }
}
public void Activate(Actor collector)
{
collector.World.AddFrameEndTask(w =>
{
var amount = self.Info.Traits.Get<GiveCashCrateActionInfo>().Amount;
collector.Owner.GiveCash(amount);
w.Add(new CrateEffect(collector, "dollar"));
});
}
}
}