crude approximation, but it works.
This commit is contained in:
34
OpenRa.Game/Effects/Demolition.cs
Normal file
34
OpenRa.Game/Effects/Demolition.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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,6 +81,7 @@
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\Demolition.cs" />
|
||||
<Compile Include="Effects\MoveFlash.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
<Compile Include="Effects\TeslaZap.cs" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
@@ -18,11 +19,8 @@ namespace OpenRa.Game.Traits.Activities
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (target == null || target.IsDead) return NextActivity;
|
||||
|
||||
// 1. run to adj tile
|
||||
// 2. spawn timed demolition (for +3/4s)
|
||||
// 3. run away --- where?
|
||||
return this;
|
||||
Game.world.AddFrameEndTask(w => w.Add(new Demolition(self, target, 25 * 2)));
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace OpenRa.Game.Traits
|
||||
if (order.OrderString == "C4")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 2));
|
||||
self.QueueActivity(new Demolish(order.TargetActor));
|
||||
self.QueueActivity(new Move(self.Location, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user