Add BeamRenderable for lasers.

This commit is contained in:
Paul Chote
2013-06-16 19:25:05 +12:00
parent 1eb04a70a5
commit 82059dca6d
3 changed files with 78 additions and 22 deletions

View File

@@ -78,34 +78,21 @@ namespace OpenRA.Mods.RA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (ticks < info.BeamDuration)
{
var src = new PPos(args.src.X, args.src.Y).ToWPos(args.srcAltitude);
var dest = new PPos(args.dest.X, args.dest.Y).ToWPos(args.destAltitude);
var rc = Color.FromArgb((info.BeamDuration - ticks)*255/info.BeamDuration, color);
yield return new BeamRenderable(src, 0, dest - src, info.BeamWidth, rc);
}
if (hitanim != null)
yield return new SpriteRenderable(hitanim.Image, args.dest.ToFloat2(),
wr.Palette("effect"), (int)args.dest.Y);
if (ticks >= info.BeamDuration)
yield break;
var rc = Color.FromArgb((info.BeamDuration - ticks)*255/info.BeamDuration, color);
var src = new PPos(args.src.X, args.src.Y - args.srcAltitude);
var dest = new PPos(args.dest.X, args.dest.Y - args.destAltitude);
var wlr = Game.Renderer.WorldLineRenderer;
// TODO: Push this into a BeamRenderable, with support for refraction/ripples on sonic weapons
var lineWidth = wlr.LineWidth;
if (lineWidth != info.BeamWidth)
{
wlr.Flush();
wlr.LineWidth = info.BeamWidth;
}
wlr.DrawLine(src.ToFloat2(), dest.ToFloat2(), rc, rc);
if (lineWidth != info.BeamWidth)
{
wlr.Flush();
wlr.LineWidth = lineWidth;
}
}
}
}