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