Ditto for Corpse.
This commit is contained in:
@@ -13,10 +13,11 @@ using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
|
||||
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 CorpseSequence = "die-crushed";
|
||||
@@ -29,11 +30,13 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly CrushableInfantryInfo Info;
|
||||
readonly RenderInfantry ri;
|
||||
|
||||
public CrushableInfantry(Actor self, CrushableInfantryInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.Info = info;
|
||||
ri = self.Trait<RenderInfantry>();
|
||||
}
|
||||
|
||||
public void WarnCrush(Actor crusher)
|
||||
@@ -45,12 +48,7 @@ namespace OpenRA.Mods.RA
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
Sound.Play(Info.CrushSound, crusher.CenterLocation);
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (!self.Destroyed)
|
||||
w.Add(new Corpse(self, Info.CorpseSequence));
|
||||
});
|
||||
|
||||
ri.SpawnCorpse(self, Info.CorpseSequence);
|
||||
self.Kill(crusher);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,25 +19,21 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly float2 pos;
|
||||
readonly RenderSimple rs;
|
||||
readonly Player p;
|
||||
readonly string paletteName;
|
||||
|
||||
public Corpse(Actor fromActor, string sequence)
|
||||
public Corpse(World world, float2 pos, string image, string sequence, string paletteName)
|
||||
{
|
||||
p = fromActor.Owner;
|
||||
rs = fromActor.Trait<RenderSimple>();
|
||||
anim = new Animation(rs.GetImage(fromActor));
|
||||
anim.PlayThen(sequence,
|
||||
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
|
||||
pos = fromActor.CenterLocation.ToFloat2();
|
||||
this.pos = pos;
|
||||
this.paletteName = paletteName;
|
||||
anim = new Animation(image);
|
||||
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick(World world) { anim.Tick(); }
|
||||
|
||||
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;
|
||||
|
||||
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 =>
|
||||
{
|
||||
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