Remove redundant FindActorsInBox helpers.
This commit is contained in:
@@ -20,17 +20,6 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public static class WorldUtils
|
public static class WorldUtils
|
||||||
{
|
{
|
||||||
public static IEnumerable<Actor> 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<Actor> FindActorsInBox(this World world, WPos tl, WPos br)
|
|
||||||
{
|
|
||||||
return world.ActorMap.ActorsInBox(tl, br);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Actor ClosestTo(this IEnumerable<Actor> actors, Actor a)
|
public static Actor ClosestTo(this IEnumerable<Actor> actors, Actor a)
|
||||||
{
|
{
|
||||||
return actors.ClosestTo(a.CenterPosition);
|
return actors.ClosestTo(a.CenterPosition);
|
||||||
@@ -48,7 +37,7 @@ namespace OpenRA
|
|||||||
// Target ranges are calculated in 2D, so ignore height differences
|
// Target ranges are calculated in 2D, so ignore height differences
|
||||||
var vec = new WVec(r, r, WRange.Zero);
|
var vec = new WVec(r, r, WRange.Zero);
|
||||||
var rSq = r.Range*r.Range;
|
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);
|
a => (a.CenterPosition - origin).HorizontalLengthSquared <= rSq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Update connection to neighbours
|
// Update connection to neighbours
|
||||||
var vec = new CVec(1, 1);
|
var adjacentActors = CVec.directions.SelectMany(dir =>
|
||||||
var adjacentActors = self.World.FindActorsInBox(self.Location - vec, self.Location + vec);
|
self.World.ActorMap.GetUnitsAt(self.Location + dir));
|
||||||
|
|
||||||
adjacent = 0;
|
adjacent = 0;
|
||||||
foreach (var a in adjacentActors)
|
foreach (var a in adjacentActors)
|
||||||
@@ -79,12 +79,12 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
static void UpdateNeighbours(Actor self)
|
static void UpdateNeighbours(Actor self)
|
||||||
{
|
{
|
||||||
var vec = new CVec(1, 1);
|
var adjacentActors = CVec.directions.SelectMany(dir =>
|
||||||
var neighbours = self.World.FindActorsInBox(self.Location - vec, self.Location + vec)
|
self.World.ActorMap.GetUnitsAt(self.Location + dir))
|
||||||
.Select(a => a.TraitOrDefault<RenderBuildingWall>())
|
.Select(a => a.TraitOrDefault<RenderBuildingWall>())
|
||||||
.Where(a => a != null);
|
.Where(a => a != null);
|
||||||
|
|
||||||
foreach (var rb in neighbours)
|
foreach (var rb in adjacentActors)
|
||||||
rb.dirty = true;
|
rb.dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
[LuaGlobal]
|
[LuaGlobal]
|
||||||
public Actor[] FindActorsInBox(WPos topLeft, WPos bottomRight)
|
public Actor[] FindActorsInBox(WPos topLeft, WPos bottomRight)
|
||||||
{
|
{
|
||||||
return world.FindActorsInBox(topLeft, bottomRight).ToArray();
|
return world.ActorMap.ActorsInBox(topLeft, bottomRight).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaGlobal]
|
[LuaGlobal]
|
||||||
|
|||||||
Reference in New Issue
Block a user