diff --git a/OpenRa.Game/Effects/DelayedAction.cs b/OpenRa.Game/Effects/DelayedAction.cs new file mode 100644 index 0000000000..01004f24a7 --- /dev/null +++ b/OpenRa.Game/Effects/DelayedAction.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Game.Traits; + +namespace OpenRa.Game.Effects +{ + class DelayedAction : IEffect + { + Action a; + int delay; + + public DelayedAction(int delay, Action a) + { + this.a = a; + this.delay = delay; + } + + public void Tick() + { + if (--delay <= 0) + Game.world.AddFrameEndTask(w => { w.Remove(this); a(); }); + } + + public IEnumerable Render() { yield break; } + } +} diff --git a/OpenRa.Game/Effects/Demolition.cs b/OpenRa.Game/Effects/Demolition.cs deleted file mode 100644 index aca6472949..0000000000 --- a/OpenRa.Game/Effects/Demolition.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenRa.Game.Traits; - -namespace OpenRa.Game.Effects -{ - class Demolition : IEffect - { - Actor attacker; - Actor target; - int delay; - - public Demolition(Actor attacker, Actor target, int delay) - { - this.attacker = attacker; - this.target = target; - this.delay = delay; - } - - public void Tick() - { - if (--delay <= 0) - Game.world.AddFrameEndTask(w => - { - w.Remove(this); - target.InflictDamage(attacker, target.Health, Rules.WarheadInfo["DemolishWarhead"]); - }); - } - - public IEnumerable Render() { yield break; } - } -} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index fcd353137c..9fc9b0bf7d 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -81,7 +81,7 @@ - + diff --git a/OpenRa.Game/Traits/Activities/Demolish.cs b/OpenRa.Game/Traits/Activities/Demolish.cs index 6f8bb76be6..4e085bc0fe 100644 --- a/OpenRa.Game/Traits/Activities/Demolish.cs +++ b/OpenRa.Game/Traits/Activities/Demolish.cs @@ -19,7 +19,8 @@ namespace OpenRa.Game.Traits.Activities public IActivity Tick(Actor self) { if (target == null || target.IsDead) return NextActivity; - Game.world.AddFrameEndTask(w => w.Add(new Demolition(self, target, 25 * 2))); + Game.world.AddFrameEndTask(w => w.Add(new DelayedAction(25*2, + () => target.InflictDamage(self, target.Health, Rules.WarheadInfo["DemolishWarhead"])))); return NextActivity; }