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

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities
{
public abstract class HarvesterDockSequence : Activity
{
protected enum DockingState { Wait, Turn, Dock, Loop, Undock, Complete }
protected enum DockingState { Wait, Turn, Dock, Loop, Undock, Complete, Finished }
protected readonly Actor Refinery;
protected readonly Harvester Harv;
@@ -47,34 +47,54 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self)
{
if (ChildActivity != null)
{
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
return this;
}
switch (dockingState)
{
case DockingState.Wait:
return this;
case DockingState.Turn:
dockingState = DockingState.Dock;
QueueChild(self, new Turn(self, DockAngle), true);
if (IsDragRequired)
return ActivityUtils.SequenceActivities(self, new Turn(self, DockAngle), new Drag(self, StartDrag, EndDrag, DragLength), this);
return ActivityUtils.SequenceActivities(self, new Turn(self, DockAngle), this);
QueueChild(self, new Drag(self, StartDrag, EndDrag, DragLength));
return this;
case DockingState.Dock:
if (Refinery.IsInWorld && !Refinery.IsDead)
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
nd.Docked(Refinery, self);
return OnStateDock(self);
case DockingState.Loop:
if (!Refinery.IsInWorld || Refinery.IsDead || Harv.TickUnload(self, Refinery))
dockingState = DockingState.Undock;
return this;
case DockingState.Undock:
return OnStateUndock(self);
case DockingState.Complete:
if (Refinery.IsInWorld && !Refinery.IsDead)
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
nd.Undocked(Refinery, self);
Harv.LastLinkedProc = Harv.LinkedProc;
Harv.LinkProc(self, null);
if (IsDragRequired)
return ActivityUtils.SequenceActivities(self, new Drag(self, EndDrag, StartDrag, DragLength), NextActivity);
QueueChild(self, new Drag(self, EndDrag, StartDrag, DragLength), true);
dockingState = DockingState.Finished;
return this;
case DockingState.Finished:
return NextActivity;
}