Ditto for Corpse.
This commit is contained in:
@@ -13,10 +13,11 @@ using System.Linq;
|
|||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
using OpenRA.Mods.RA.Move;
|
using OpenRA.Mods.RA.Move;
|
||||||
|
using OpenRA.Mods.RA.Render;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class CrushableInfantryInfo : ITraitInfo, Requires<MobileInfo>
|
class CrushableInfantryInfo : ITraitInfo, Requires<MobileInfo>, Requires<RenderInfantryInfo>
|
||||||
{
|
{
|
||||||
public readonly string CrushSound = "squish2.aud";
|
public readonly string CrushSound = "squish2.aud";
|
||||||
public readonly string CorpseSequence = "die-crushed";
|
public readonly string CorpseSequence = "die-crushed";
|
||||||
@@ -29,11 +30,13 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly CrushableInfantryInfo Info;
|
readonly CrushableInfantryInfo Info;
|
||||||
|
readonly RenderInfantry ri;
|
||||||
|
|
||||||
public CrushableInfantry(Actor self, CrushableInfantryInfo info)
|
public CrushableInfantry(Actor self, CrushableInfantryInfo info)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
|
ri = self.Trait<RenderInfantry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WarnCrush(Actor crusher)
|
public void WarnCrush(Actor crusher)
|
||||||
@@ -45,12 +48,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
{
|
{
|
||||||
Sound.Play(Info.CrushSound, crusher.CenterLocation);
|
Sound.Play(Info.CrushSound, crusher.CenterLocation);
|
||||||
self.World.AddFrameEndTask(w =>
|
ri.SpawnCorpse(self, Info.CorpseSequence);
|
||||||
{
|
|
||||||
if (!self.Destroyed)
|
|
||||||
w.Add(new Corpse(self, Info.CorpseSequence));
|
|
||||||
});
|
|
||||||
|
|
||||||
self.Kill(crusher);
|
self.Kill(crusher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,25 +19,21 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
{
|
{
|
||||||
readonly Animation anim;
|
readonly Animation anim;
|
||||||
readonly float2 pos;
|
readonly float2 pos;
|
||||||
readonly RenderSimple rs;
|
readonly string paletteName;
|
||||||
readonly Player p;
|
|
||||||
|
|
||||||
public Corpse(Actor fromActor, string sequence)
|
public Corpse(World world, float2 pos, string image, string sequence, string paletteName)
|
||||||
{
|
{
|
||||||
p = fromActor.Owner;
|
this.pos = pos;
|
||||||
rs = fromActor.Trait<RenderSimple>();
|
this.paletteName = paletteName;
|
||||||
anim = new Animation(rs.GetImage(fromActor));
|
anim = new Animation(image);
|
||||||
anim.PlayThen(sequence,
|
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
|
||||||
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
|
|
||||||
|
|
||||||
pos = fromActor.CenterLocation.ToFloat2();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( World world ) { anim.Tick(); }
|
public void Tick(World world) { anim.Tick(); }
|
||||||
|
|
||||||
public IEnumerable<Renderable> Render(WorldRenderer wr)
|
public IEnumerable<Renderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, rs.Palette(p, wr), (int)pos.Y);
|
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, wr.Palette(paletteName), (int)pos.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,10 +124,16 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
|
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
|
||||||
|
SpawnCorpse(self, "die{0}".F(e.Warhead.InfDeath));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SpawnCorpse(Actor self, string sequence)
|
||||||
|
{
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
if (!self.Destroyed)
|
if (!self.Destroyed)
|
||||||
w.Add(new Corpse(self, "die{0}".F(e.Warhead.InfDeath)));
|
w.Add(new Corpse(w, self.CenterLocation.ToFloat2(), GetImage(self),
|
||||||
|
sequence, Info.PlayerPalette+self.Owner.InternalName));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user