harvester Deliver order works with queues

This commit is contained in:
tovl
2019-02-01 23:39:07 +01:00
committed by reaperrr
parent f64c8f1ee8
commit 307a87cd9e
4 changed files with 49 additions and 15 deletions

View File

@@ -30,12 +30,17 @@ namespace OpenRA.Mods.Common.Activities
{
movement = self.Trait<IMove>();
harv = self.Trait<Harvester>();
IsInterruptible = false;
}
public override Activity Tick(Actor self)
{
if (NextActivity != null)
if (ChildActivity != null)
{
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
return this;
}
if (IsCanceling || isDocking)
return NextActivity;
// Find the nearest best refinery if not explicitly ordered to a specific refinery:
@@ -57,7 +62,10 @@ namespace OpenRA.Mods.Common.Activities
// No refineries exist; check again after delay defined in Harvester.
if (harv.LinkedProc == null)
return ActivityUtils.SequenceActivities(self, new Wait(harv.Info.SearchForDeliveryBuildingDelay), this);
{
QueueChild(self, new Wait(harv.Info.SearchForDeliveryBuildingDelay), true);
return this;
}
var proc = harv.LinkedProc;
var iao = proc.Trait<IAcceptResources>();
@@ -68,16 +76,19 @@ namespace OpenRA.Mods.Common.Activities
foreach (var n in self.TraitsImplementing<INotifyHarvesterAction>())
n.MovingToRefinery(self, proc, null);
return ActivityUtils.SequenceActivities(self, movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), this);
QueueChild(self, movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), true);
return this;
}
if (!isDocking)
{
QueueChild(self, new Wait(10), true);
isDocking = true;
iao.OnDock(self, this);
return this;
}
return ActivityUtils.SequenceActivities(self, new Wait(10), this);
return NextActivity;
}
}
}