Skip to content

Commit

Permalink
Refinery spawned harvesters should prioritize lower ore #14827
Browse files Browse the repository at this point in the history
  • Loading branch information
CJure committed Mar 7, 2018
1 parent fadcfa0 commit 0440094
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion OpenRA.Mods.Common/Activities/FindResources.cs
Expand Up @@ -121,7 +121,7 @@ public override Activity Tick(Actor self)
return self.Location;

// Determine where to search from and how far to search:
var searchFromLoc = harv.LastOrderLocation ?? (harv.LastLinkedProc ?? harv.LinkedProc ?? self).Location;
var searchFromLoc = GetFromSearchLocation(self);
var searchRadius = harv.LastOrderLocation.HasValue ? harvInfo.SearchFromOrderRadius : harvInfo.SearchFromProcRadius;
var searchRadiusSquared = searchRadius * searchRadius;

Expand Down Expand Up @@ -152,5 +152,16 @@ public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromCell(self.World, self.Location);
}

private CPos GetFromSearchLocation(Actor self)
{
if (harv.LastOrderLocation.HasValue)
return harv.LastOrderLocation.Value;
else if (harv.LastLinkedProc != null)
return harv.LastLinkedProc.Location + harv.LastLinkedProc.Trait<IAcceptResources>().DeliveryOffset;
else if (harv.LinkedProc != null)
return harv.LinkedProc.Location + harv.LinkedProc.Trait<IAcceptResources>().DeliveryOffset;
return self.Location;
}
}
}

0 comments on commit 0440094

Please sign in to comment.