diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 98fab7a439..0dc6f38031 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -200,6 +200,20 @@ namespace OpenRA.Graphics wlr.LineWidth = oldWidth; } + public void DrawTargetMarker(Color c, float2 location) + { + var tl = new float2(-1, -1); + var br = new float2(1, 1); + var bl = new float2(tl.X, br.Y); + var tr = new float2(br.X, tl.Y); + + var wlr = Game.Renderer.WorldLineRenderer; + wlr.DrawLine(location + tl, location + tr, c, c); + wlr.DrawLine(location + tr, location + br, c, c); + wlr.DrawLine(location + br, location + bl, c, c); + wlr.DrawLine(location + bl, location + tl, c, c); + } + public void RefreshPalette() { palette.ApplyModifiers(world.WorldActor.TraitsImplementing()); diff --git a/OpenRA.Game/Traits/DrawLineToTarget.cs b/OpenRA.Game/Traits/DrawLineToTarget.cs index a0fb811743..2fa04f64f1 100644 --- a/OpenRA.Game/Traits/DrawLineToTarget.cs +++ b/OpenRA.Game/Traits/DrawLineToTarget.cs @@ -60,27 +60,17 @@ namespace OpenRA.Traits return; var from = wr.ScreenPxPosition(self.CenterPosition); - var wlr = Game.Renderer.WorldLineRenderer; - foreach (var target in targets) { if (target.Type == TargetType.Invalid) continue; var to = wr.ScreenPxPosition(target.CenterPosition); - wlr.DrawLine(from, to, c, c); - DrawTargetMarker(wlr, from); - DrawTargetMarker(wlr, to); + Game.Renderer.WorldLineRenderer.DrawLine(from, to, c, c); + wr.DrawTargetMarker(c, from); + wr.DrawTargetMarker(c, to); } } - - 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); - } } public static class LineTargetExts @@ -89,12 +79,7 @@ namespace OpenRA.Traits { var line = self.TraitOrDefault(); if (line != null) - { - self.World.AddFrameEndTask(w => - { - line.SetTargets(self, targets, color, false); - }); - } + self.World.AddFrameEndTask(w => line.SetTargets(self, targets, color, false)); } public static void SetTargetLine(this Actor self, Target target, Color color) diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index b01cc222c8..d1d3f402d4 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -154,7 +154,8 @@ namespace OpenRA.Traits void DrawUnitPath(WorldRenderer wr, Actor self) { - if (self.World.LocalPlayer == null ||!self.World.LocalPlayer.PlayerActor.Trait().PathDebug) return; + if (self.World.LocalPlayer == null || !self.World.LocalPlayer.PlayerActor.Trait().PathDebug) + return; var activity = self.GetCurrentActivity(); if (activity != null) @@ -163,15 +164,10 @@ namespace OpenRA.Traits var start = wr.ScreenPxPosition(self.CenterPosition); var c = Color.Green; - - var wlr = Game.Renderer.WorldLineRenderer; - foreach (var stp in targets.Where(t => t.Type != TargetType.Invalid).Select(p => wr.ScreenPxPosition(p.CenterPosition))) + foreach (var stp in targets.Where(t => t.Type != TargetType.Invalid).Select(pos => wr.ScreenPxPosition(pos.CenterPosition))) { - wlr.DrawLine(stp + new float2(-1, -1), stp + new float2(-1, 1), c, c); - wlr.DrawLine(stp + new float2(-1, 1), stp + new float2(1, 1), c, c); - wlr.DrawLine(stp + new float2(1, 1), stp + new float2(1, -1), c, c); - wlr.DrawLine(stp + new float2(1, -1), stp + new float2(-1, -1), c, c); - wlr.DrawLine(start, stp, c, c); + Game.Renderer.WorldLineRenderer.DrawLine(start, stp, c, c); + wr.DrawTargetMarker(c, stp); start = stp; } } diff --git a/OpenRA.Mods.RA/CombatDebugOverlay.cs b/OpenRA.Mods.RA/CombatDebugOverlay.cs index 2d4bf79c06..cae695026b 100755 --- a/OpenRA.Mods.RA/CombatDebugOverlay.cs +++ b/OpenRA.Mods.RA/CombatDebugOverlay.cs @@ -52,6 +52,7 @@ namespace OpenRA.Mods.RA var c = Color.White; foreach (var a in armaments.Value) + { foreach (var b in a.Barrels) { var muzzle = self.CenterPosition + a.MuzzleOffset(self, b); @@ -60,11 +61,9 @@ namespace OpenRA.Mods.RA var sm = wr.ScreenPosition(muzzle); var sd = wr.ScreenPosition(muzzle + dirOffset); wlr.DrawLine(sm, sd, c, c); - wlr.DrawLine(sm + new float2(-1, -1), sm + new float2(-1, 1), c, c); - wlr.DrawLine(sm + new float2(-1, 1), sm + new float2(1, 1), c, c); - wlr.DrawLine(sm + new float2(1, 1), sm + new float2(1, -1), c, c); - wlr.DrawLine(sm + new float2(1, -1), sm + new float2(-1, -1), c, c); + wr.DrawTargetMarker(c, sm); } + } } } }