Remove a pile of duplication from target lines.

Remove MoveFlash.
This commit is contained in:
Paul Chote
2010-11-26 14:30:33 +13:00
parent 5f43923b80
commit b423889c06
21 changed files with 62 additions and 251 deletions

View File

@@ -9,7 +9,8 @@
#endregion
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Graphics;
using OpenRA.Effects;
namespace OpenRA.Traits
{
@@ -69,6 +70,34 @@ namespace OpenRA.Traits
Game.Renderer.LineRenderer.DrawLine(p + new float2(1, -1), p + new float2(-1, -1), c, c);
}
}
}
public static class LineTargetExts
{
public static void SetTargetLine(this Actor self, Target target, Color color)
{
self.SetTargetLine(target, color, true);
}
public static void SetTargetLine(this Actor self, Target target, Color color, bool display)
{
if (self.Owner != self.World.LocalPlayer)
return;
self.World.AddFrameEndTask(w =>
{
if (self.Destroyed) return;
if (target.IsActor && display)
w.Add(new FlashTarget(target.Actor));
var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null)
if (display)
line.SetTarget(self, target, color);
else
line.SetTargetSilently(self, target, color);
});
}
}
}