fixed #999 -- replace order/first[ordefault] with .ClosestTo(point)

This commit is contained in:
Chris Forbes
2011-07-08 23:01:05 +12:00
committed by Paul Chote
parent 5c3a6c81ae
commit e44b965785
7 changed files with 18 additions and 18 deletions

View File

@@ -34,6 +34,11 @@ namespace OpenRA
return world.WorldActor.Trait<SpatialBins>().ActorsInBox(u,v);
}
public static Actor ClosestTo( this IEnumerable<Actor> actors, int2 px )
{
return actors.OrderBy( a => (a.CenterLocation - px).LengthSquared ).FirstOrDefault();
}
public static IEnumerable<Actor> FindUnitsInCircle(this World world, int2 a, int r)
{
using (new PerfSample("FindUnitsInCircle"))