bring back AI search for new resource patches avoiding enemies

This commit is contained in:
Matthias Mailänder
2015-09-04 14:30:12 +02:00
parent 91c7d7893e
commit 0df8b3ba39
3 changed files with 61 additions and 24 deletions

View File

@@ -117,5 +117,26 @@ 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)
{
var resType = resLayer.GetResource(pos);
if (resType == null)
return false;
// Can the harvester collect this kind of resource?
if (!harvInfo.Resources.Contains(resType.Info.Name))
return false;
if (territory != null)
{
// Another harvester has claimed this resource:
ResourceClaim claim;
if (territory.IsClaimedByAnyoneElse(self as Actor, pos, out claim))
return false;
}
return true;
}
}
}