infantry deaths (handled by Corpse effect)
This commit is contained in:
@@ -106,7 +106,7 @@ namespace OpenRa.Game
|
||||
|
||||
public bool IsDead { get { return Health <= 0; } }
|
||||
|
||||
public void InflictDamage(Actor attacker, int damage)
|
||||
public void InflictDamage(Actor attacker, int damage, WarheadInfo warhead)
|
||||
{
|
||||
/* todo: auto-retaliate, etc */
|
||||
/* todo: death sequence for infantry based on inflictor */
|
||||
@@ -138,7 +138,7 @@ namespace OpenRa.Game
|
||||
}
|
||||
|
||||
foreach (var ndx in traits.WithInterface<INotifyDamageEx>())
|
||||
ndx.Damaged(this, damage);
|
||||
ndx.Damaged(this, damage, warhead);
|
||||
}
|
||||
|
||||
public void QueueActivity( IActivity nextActivity )
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game
|
||||
var hitActors = Game.FindUnitsInCircle(loc, maxSpread);
|
||||
|
||||
foreach (var victim in hitActors)
|
||||
victim.InflictDamage(firedBy, (int)GetDamageToInflict(victim, loc, weapon, warhead));
|
||||
victim.InflictDamage(firedBy, (int)GetDamageToInflict(victim, loc, weapon, warhead), warhead);
|
||||
}
|
||||
|
||||
static float GetMaximumSpread(WeaponInfo weapon, WarheadInfo warhead)
|
||||
|
||||
32
OpenRa.Game/Effects/Corpse.cs
Normal file
32
OpenRa.Game/Effects/Corpse.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Effects
|
||||
{
|
||||
class Corpse : IEffect
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly float2 pos;
|
||||
readonly Player owner;
|
||||
|
||||
public Corpse(Actor fromActor, int death)
|
||||
{
|
||||
anim = new Animation(fromActor.Info.Image ?? fromActor.Info.Name);
|
||||
anim.PlayThen("die{0}".F(death + 1),
|
||||
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
|
||||
|
||||
pos = fromActor.CenterLocation;
|
||||
owner = fromActor.Owner;
|
||||
}
|
||||
|
||||
public void Tick() { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Tuple<Sprite, float2, int>> Render()
|
||||
{
|
||||
yield return Tuple.New(anim.Image, pos - .5f * anim.Image.size, owner.Palette);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="Chat.cs" />
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
<Compile Include="Effects\TeslaZap.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
|
||||
@@ -3,10 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderInfantry : RenderSimple, INotifyAttack
|
||||
class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamageEx
|
||||
{
|
||||
public RenderInfantry(Actor self)
|
||||
: base(self)
|
||||
@@ -57,5 +59,13 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
yield return Util.Centered(self, anim.Image, self.CenterLocation);
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, int damage, WarheadInfo warhead)
|
||||
{
|
||||
if (self.Health <= 0)
|
||||
Game.world.AddFrameEndTask(w => w.Add(new Corpse(self, warhead.InfDeath)));
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, DamageState ds) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
@@ -37,7 +38,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public void Damaged(Actor self, DamageState ds) { currentDs = ds; }
|
||||
|
||||
public void Damaged(Actor self, int damage)
|
||||
public void Damaged(Actor self, int damage, WarheadInfo warhead)
|
||||
{
|
||||
if (currentDs != DamageState.Half) return;
|
||||
if (!isSmoking)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits
|
||||
interface ITick { void Tick(Actor self); }
|
||||
interface IRender { IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self); }
|
||||
interface INotifyDamage { void Damaged(Actor self, DamageState ds); }
|
||||
interface INotifyDamageEx : INotifyDamage { void Damaged(Actor self, int damage); }
|
||||
interface INotifyDamageEx : INotifyDamage { void Damaged(Actor self, int damage, WarheadInfo warhead); }
|
||||
interface INotifyBuildComplete { void BuildingComplete (Actor self); }
|
||||
interface IOrder
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user