Convert Explosion to world coords.

This commit is contained in:
Paul Chote
2013-07-06 21:44:39 +12:00
parent 01de84e9fc
commit 1e7f1ab225
3 changed files with 7 additions and 13 deletions

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
if (explosionType != null)
world.AddFrameEndTask(
w => w.Add(new Explosion(w, args.dest, explosionType, isWater, args.destAltitude)));
w => w.Add(new Explosion(w, args.dest.ToWPos(args.destAltitude), explosionType)));
Sound.Play(GetImpactSound(warhead, isWater), args.dest);

View File

@@ -18,26 +18,20 @@ namespace OpenRA.Mods.RA.Effects
public class Explosion : IEffect
{
Animation anim;
PPos pos;
int altitude;
WPos pos;
public Explosion(World world, PPos pixelPos, string style, bool isWater, int altitude)
public Explosion(World world, WPos pos, string style)
{
this.pos = pixelPos;
this.altitude = altitude;
this.pos = pos;
anim = new Animation("explosion");
anim.PlayThen(style,
() => world.AddFrameEndTask(w => w.Remove(this)));
anim.PlayThen(style, () => world.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick( World world ) { anim.Tick(); }
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
var p = pos.ToInt2() - new int2(0, altitude);
yield return new SpriteRenderable(anim.Image, p, wr.Palette("effect"), p.Y);
yield return new SpriteRenderable(anim.Image, pos, 0, wr.Palette("effect"), 1f);
}
public Player Owner { get { return null; } }
}
}

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Render
var bi = self.Info.Traits.Get<BuildingInfo>();
FootprintUtils.UnpathableTiles(self.Info.Name, bi, self.Location).Do(
t => self.World.AddFrameEndTask(
w => w.Add(new Explosion(w, Traits.Util.CenterOfCell(t), "building", false, 0))));
w => w.Add(new Explosion(w, t.CenterPosition, "building"))));
}
}
}