Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using OpenRA.Traits;
- using System;
- using OpenRA.Mods.Common.Effects;
- namespace OpenRA.Mods.Common.Traits
- {
- class BloodCashTricklerInfo : ITraitInfo
- {
- public readonly int Delay = 50;
- public readonly int Percentage = 30;
- public object Create(ActorInitializer init) { return new BloodCashTrickler(init.Self, this); }
- }
- class BloodCashTrickler : ITick, ISync
- {
- readonly BloodCashTricklerInfo info;
- [Sync] int ticks;
- List< Tuple<int,int> > timesAndBounties = new List<Tuple<int,int> >();
- public BloodCashTrickler(Actor self, BloodCashTricklerInfo info)
- {
- this.info = info;
- }
- public void Tick(Actor self)
- {
- ++ticks;
- if (timesAndBounties.Count > 0 && ticks == timesAndBounties[0].Item1)
- {
- var cash = timesAndBounties[0].Item2;
- timesAndBounties.RemoveAt(0);
- self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(cash);
- self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(cash), 30)));
- }
- }
- public void GiveBloodCash(int x)
- {
- timesAndBounties.Add(new Tuple<int,int>(ticks + info.Delay, x * info.Percentage / 100));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement