Let harvesters only search for refineries when needing to unload.
This commit is contained in:
@@ -177,13 +177,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Determine where to search from and how far to search:
|
||||
var procLoc = GetSearchFromProcLocation(self);
|
||||
var searchFromLoc = lastHarvestedCell ?? procLoc;
|
||||
var searchFromLoc = lastHarvestedCell ?? procLoc ?? self.Location;
|
||||
var searchRadius = lastHarvestedCell.HasValue ? harvInfo.SearchFromHarvesterRadius : harvInfo.SearchFromProcRadius;
|
||||
if (!searchFromLoc.HasValue)
|
||||
{
|
||||
searchFromLoc = self.Location;
|
||||
searchRadius = harvInfo.SearchFromHarvesterRadius;
|
||||
}
|
||||
|
||||
var searchRadiusSquared = searchRadius * searchRadius;
|
||||
|
||||
@@ -196,7 +191,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
domainIndex.IsPassable(self.Location, loc, mobile.Locomotor) && harv.CanHarvestCell(self, loc) && claimLayer.CanClaimCell(self, loc))
|
||||
.WithCustomCost(loc =>
|
||||
{
|
||||
if ((loc - searchFromLoc.Value).LengthSquared > searchRadiusSquared)
|
||||
if ((loc - searchFromLoc).LengthSquared > searchRadiusSquared)
|
||||
return int.MaxValue;
|
||||
|
||||
// Add a cost modifier to harvestable cells to prefer resources that are closer to the refinery.
|
||||
@@ -221,7 +216,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
return 0;
|
||||
})
|
||||
.FromPoint(searchFromLoc.Value)
|
||||
.FromPoint(searchFromLoc)
|
||||
.FromPoint(self.Location))
|
||||
path = pathFinder.FindPath(search);
|
||||
|
||||
|
||||
@@ -148,8 +148,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
resourceMultipliers = self.TraitsImplementing<HarvesterResourceMultiplier>().ToArray();
|
||||
UpdateCondition(self);
|
||||
|
||||
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
||||
|
||||
// Note: This is queued in a FrameEndTask because otherwise the activity is dropped/overridden while moving out of a factory.
|
||||
if (Info.SearchOnCreation)
|
||||
self.World.AddFrameEndTask(w => self.QueueActivity(new FindAndDeliverResources(self)));
|
||||
|
||||
Reference in New Issue
Block a user