diff --git a/OpenRA.Mods.Common/ActorExts.cs b/OpenRA.Mods.Common/ActorExts.cs index 3d3633758c..651a2ba6f3 100644 --- a/OpenRA.Mods.Common/ActorExts.cs +++ b/OpenRA.Mods.Common/ActorExts.cs @@ -118,7 +118,8 @@ namespace OpenRA.Mods.Common NotifyBlocker(self, positions.SelectMany(p => self.World.ActorMap.GetUnitsAt(p))); } - public static bool CanHarvestAt(this Actor self, CPos pos, ResourceLayer resLayer, HarvesterInfo harvInfo, ResourceClaimLayer territory) + public static bool CanHarvestAt(this Actor self, CPos pos, ResourceLayer resLayer, HarvesterInfo harvInfo, + ResourceClaimLayer territory) { var resType = resLayer.GetResource(pos); if (resType == null) @@ -138,5 +139,10 @@ namespace OpenRA.Mods.Common return true; } + + public static CPos ClosestCell(this Actor self, IEnumerable cells) + { + return cells.MinByOrDefault(c => (self.Location - c).LengthSquared); + } } }