From b7b2db9ace2b81367b29b32d6ec21687bde32e67 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 21 Oct 2011 16:34:54 +1300 Subject: [PATCH] remove some insanity in DrawLineToTarget --- OpenRA.Game/Traits/DrawLineToTarget.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/OpenRA.Game/Traits/DrawLineToTarget.cs b/OpenRA.Game/Traits/DrawLineToTarget.cs index 231fd1fdc3..aa17f3a954 100644 --- a/OpenRA.Game/Traits/DrawLineToTarget.cs +++ b/OpenRA.Game/Traits/DrawLineToTarget.cs @@ -57,19 +57,22 @@ namespace OpenRA.Traits if (!target.IsValid) return; - var p = target.CenterLocation; var move = self.TraitOrDefault(); var origin = move != null ? self.CenterLocation - new int2(0, move.Altitude) : self.CenterLocation; var wlr = Game.Renderer.WorldLineRenderer; - wlr.DrawLine(origin, p, c, c); - for (bool b = false; !b; p = origin, b = true) - { - wlr.DrawLine(p + new float2(-1, -1), p + new float2(-1, 1), c, c); - wlr.DrawLine(p + new float2(-1, 1), p + new float2(1, 1), c, c); - wlr.DrawLine(p + new float2(1, 1), p + new float2(1, -1), c, c); - wlr.DrawLine(p + new float2(1, -1), p + new float2(-1, -1), c, c); - } + + wlr.DrawLine(origin, target.CenterLocation, c, c); + DrawTargetMarker(wlr, target.CenterLocation); + DrawTargetMarker(wlr, origin); + } + + void DrawTargetMarker(LineRenderer wlr, float2 p) + { + wlr.DrawLine(p + new float2(-1, -1), p + new float2(-1, 1), c, c); + wlr.DrawLine(p + new float2(-1, 1), p + new float2(1, 1), c, c); + wlr.DrawLine(p + new float2(1, 1), p + new float2(1, -1), c, c); + wlr.DrawLine(p + new float2(1, -1), p + new float2(-1, -1), c, c); } }