diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 9060345e80..47aab50cfd 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -341,27 +341,30 @@ namespace OpenRA.Graphics } } - public void DrawRangeCircle(Color c, int2 location, int range) + public void DrawLocus(Color c, int2[] cells) { - var r2 = range * range; - - foreach (var t in world.FindTilesInCircle(location, range)) + foreach (var t in cells) { - if ((location - t - new int2(-1, 0)).LengthSquared > r2) + if (!cells.Contains(t + new int2(-1, 0))) lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)), c, c); - if ((location - t - new int2(1, 0)).LengthSquared > r2) + if (!cells.Contains(t + new int2(1, 0))) lineRenderer.DrawLine(Game.CellSize * (t + new int2(1, 0)), Game.CellSize * (t + new int2(1, 1)), c, c); - if ((location - t - new int2(0, -1)).LengthSquared > r2) + if (!cells.Contains(t + new int2(0, -1))) lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1, 0)), c, c); - if ((location - t - new int2(0, 1)).LengthSquared > r2) + if (!cells.Contains(t + new int2(0, 1))) lineRenderer.DrawLine(Game.CellSize * (t + new int2(0, 1)), Game.CellSize * (t + new int2(1, 1)), c, c); } } + public void DrawRangeCircle(Color c, int2 location, int range) + { + DrawLocus(c, world.FindTilesInCircle(location, range).ToArray()); + } + public void DrawRangeCircle(Actor selectedUnit) { if (selectedUnit.Owner == world.LocalPlayer) diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index 5aa8887e32..12068e0733 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -23,13 +23,14 @@ using OpenRA.Mods.RA.Activities; using OpenRA.Traits; using System.Collections.Generic; using System; +using System.Drawing; namespace OpenRA.Mods.RA { class MinelayerInfo : TraitInfo { public readonly string Mine = "minv"; - public readonly int MinefieldDepth = 2; + public readonly float MinefieldDepth = 1.5f; public readonly string[] RearmBuildings = { "fix" }; } @@ -72,7 +73,7 @@ namespace OpenRA.Mods.RA } } - static IEnumerable GetMinefieldCells(int2 start, int2 end, int depth) + static IEnumerable GetMinefieldCells(int2 start, int2 end, float depth) { var mins = int2.Min(start, end); var maxs = int2.Max(start, end); @@ -100,6 +101,12 @@ namespace OpenRA.Mods.RA public IEnumerable Order(World world, int2 xy, MouseInput mi) { + if (mi.Button == MouseButton.Left) + { + Game.controller.CancelInputMode(); + yield break; + } + var underCursor = world.FindUnitsAtMouse(mi.Location) .Where(a => a.Info.Traits.Contains()) .OrderByDescending(a => a.Info.Traits.Get().Priority) @@ -115,9 +122,18 @@ namespace OpenRA.Mods.RA Game.controller.CancelInputMode(); } - public void Render(World world) { } + int2 lastMousePos; + public void Render(World world) + { + var ml = minelayer.traits.Get(); + var movement = minelayer.traits.Get(); + var minefield = GetMinefieldCells(ml.minefieldStart, lastMousePos, minelayer.Info.Traits.Get().MinefieldDepth) + .Where(p => movement.CanEnterCell(p)).ToArray(); - public string GetCursor(World world, int2 xy, MouseInput mi) { return "ability"; } /* todo */ + Game.world.WorldRenderer.DrawLocus(Color.Cyan, minefield); + } + + public string GetCursor(World world, int2 xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* todo */ } } }