diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 481b9a405e..daf103f579 100644 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -20,17 +20,6 @@ namespace OpenRA { public static class WorldUtils { - public static IEnumerable FindActorsInBox(this World world, CPos tl, CPos br) - { - // TODO: Support diamond boxes for isometric maps? - return world.FindActorsInBox(tl.TopLeft, br.BottomRight); - } - - public static IEnumerable FindActorsInBox(this World world, WPos tl, WPos br) - { - return world.ActorMap.ActorsInBox(tl, br); - } - public static Actor ClosestTo(this IEnumerable actors, Actor a) { return actors.ClosestTo(a.CenterPosition); @@ -48,7 +37,7 @@ namespace OpenRA // Target ranges are calculated in 2D, so ignore height differences var vec = new WVec(r, r, WRange.Zero); var rSq = r.Range*r.Range; - return world.FindActorsInBox(origin - vec, origin + vec).Where( + return world.ActorMap.ActorsInBox(origin - vec, origin + vec).Where( a => (a.CenterPosition - origin).HorizontalLengthSquared <= rSq); } } diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs index 93b95f5e93..da090cb2d6 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs @@ -51,8 +51,8 @@ namespace OpenRA.Mods.RA.Render return; // Update connection to neighbours - var vec = new CVec(1, 1); - var adjacentActors = self.World.FindActorsInBox(self.Location - vec, self.Location + vec); + var adjacentActors = CVec.directions.SelectMany(dir => + self.World.ActorMap.GetUnitsAt(self.Location + dir)); adjacent = 0; foreach (var a in adjacentActors) @@ -79,12 +79,12 @@ namespace OpenRA.Mods.RA.Render static void UpdateNeighbours(Actor self) { - var vec = new CVec(1, 1); - var neighbours = self.World.FindActorsInBox(self.Location - vec, self.Location + vec) + var adjacentActors = CVec.directions.SelectMany(dir => + self.World.ActorMap.GetUnitsAt(self.Location + dir)) .Select(a => a.TraitOrDefault()) .Where(a => a != null); - foreach (var rb in neighbours) + foreach (var rb in adjacentActors) rb.dirty = true; } diff --git a/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs b/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs index 59342d0ed7..587140e676 100644 --- a/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs +++ b/OpenRA.Mods.RA/Scripting/LuaScriptInterface.cs @@ -369,7 +369,7 @@ namespace OpenRA.Mods.RA.Scripting [LuaGlobal] public Actor[] FindActorsInBox(WPos topLeft, WPos bottomRight) { - return world.FindActorsInBox(topLeft, bottomRight).ToArray(); + return world.ActorMap.ActorsInBox(topLeft, bottomRight).ToArray(); } [LuaGlobal]