Many harvester behavior improvements; summary below.
Implemented Harvester territory marking with a simple resource claim system in ResourceClaimLayer trait added to World. Added customCost for PathSearch to support new Harvester search preferences. Explicit delivery order forces harvester to always deliver to that refinery. Explicit harvest order frees harvester from forced delivery refinery and allows for auto-balancing. Harvesters auto-balance refinery choice such that no more than 3 harvesters are linked to any one refinery at a time. Harvesters try very hard to not block the refinery dock location. Harvesters try to avoid enemy territory when searching for resources. Group-select harvest order intelligently disperses harvesters around the order location. Fixed PathFinder caching to not be a sliding window. This is a correctness issue. Sliding window causes no-route paths to be cached permanently in tight move loops and doesn't allow eventual progress to be made. This may have negative performance implications.
This commit is contained in:
@@ -18,29 +18,48 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public class DeliverResources : Activity
|
||||
{
|
||||
bool isDocking;
|
||||
int chosenTicks;
|
||||
|
||||
const int NextChooseTime = 100;
|
||||
|
||||
public DeliverResources() { }
|
||||
|
||||
public override Activity Tick( Actor self )
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if( NextActivity != null )
|
||||
if (NextActivity != null)
|
||||
return NextActivity;
|
||||
|
||||
var mobile = self.Trait<Mobile>();
|
||||
var harv = self.Trait<Harvester>();
|
||||
|
||||
// Find the nearest best refinery if not explicitly ordered to a specific refinery:
|
||||
if (harv.OwnerLinkedProc == null || !harv.OwnerLinkedProc.IsInWorld)
|
||||
{
|
||||
// Maybe we lost the owner-linked refinery:
|
||||
harv.OwnerLinkedProc = null;
|
||||
if (self.World.FrameNumber - chosenTicks > NextChooseTime)
|
||||
{
|
||||
harv.ChooseNewProc(self, null);
|
||||
chosenTicks = self.World.FrameNumber;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
harv.LinkedProc = harv.OwnerLinkedProc;
|
||||
}
|
||||
|
||||
if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld)
|
||||
harv.ChooseNewProc(self, null);
|
||||
|
||||
if (harv.LinkedProc == null) // no procs exist; check again in 1s.
|
||||
return Util.SequenceActivities( new Wait(25), this );
|
||||
return Util.SequenceActivities(new Wait(25), this);
|
||||
|
||||
var proc = harv.LinkedProc;
|
||||
var iao = proc.Trait<IAcceptOre>();
|
||||
|
||||
self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
|
||||
if( self.Location != proc.Location + iao.DeliverOffset )
|
||||
return Util.SequenceActivities( mobile.MoveTo(proc.Location + iao.DeliverOffset, 0), this );
|
||||
if (self.Location != proc.Location + iao.DeliverOffset)
|
||||
return Util.SequenceActivities(mobile.MoveTo(proc.Location + iao.DeliverOffset, 0), this);
|
||||
|
||||
if (!isDocking)
|
||||
{
|
||||
@@ -48,7 +67,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
iao.OnDock(self, this);
|
||||
}
|
||||
|
||||
return Util.SequenceActivities( new Wait(10), this );
|
||||
return Util.SequenceActivities(new Wait(10), this);
|
||||
}
|
||||
|
||||
// Cannot be cancelled
|
||||
|
||||
Reference in New Issue
Block a user