diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index ffefd3b98c..e8fc849c41 100644 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -30,6 +30,11 @@ namespace OpenRA return actors.MinByOrDefault(a => (a.CenterPosition - pos).LengthSquared); } + public static WPos PositionClosestTo(this IEnumerable positions, WPos pos) + { + return positions.MinByOrDefault(p => (p - pos).LengthSquared); + } + public static IEnumerable FindActorsInCircle(this World world, WPos origin, WDist r) { // Target ranges are calculated in 2D, so ignore height differences