generalized that hack into something that's probably useful
This commit is contained in:
28
OpenRa.Game/Effects/DelayedAction.cs
Normal file
28
OpenRa.Game/Effects/DelayedAction.cs
Normal file
@@ -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<Renderable> Render() { yield break; }
|
||||
}
|
||||
}
|
||||
@@ -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<Renderable> Render() { yield break; }
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\Demolition.cs" />
|
||||
<Compile Include="Effects\DelayedAction.cs" />
|
||||
<Compile Include="Effects\MoveFlash.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
<Compile Include="Effects\TeslaZap.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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user