Rework Carryall drop-off queueing and ordering.

This commit is contained in:
tovl
2019-04-14 10:31:44 +02:00
committed by reaperrr
parent a403d9937d
commit 0b747ba927
5 changed files with 170 additions and 179 deletions

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Activities
readonly int delay;
enum PickupState { Intercept, LockCarryable, MoveToCarryable, Turn, Land, Wait, Pickup, Aborted }
enum PickupState { Intercept, LockCarryable, MoveToCarryable, Turn, Land, Wait, Pickup }
PickupState state;
@@ -49,6 +49,11 @@ namespace OpenRA.Mods.Common.Activities
state = PickupState.Intercept;
}
protected override void OnFirstRun(Actor self)
{
carryall.ReserveCarryable(self, cargo);
}
public override Activity Tick(Actor self)
{
if (ChildActivity != null)
@@ -67,7 +72,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity;
}
if (carryall.State == Carryall.CarryallState.Idle)
if (carryall.State != Carryall.CarryallState.Reserved)
return NextActivity;
switch (state)
@@ -78,9 +83,10 @@ namespace OpenRA.Mods.Common.Activities
return this;
case PickupState.LockCarryable:
state = PickupState.MoveToCarryable;
if (!carryable.LockForPickup(cargo, self))
state = PickupState.Aborted;
Cancel(self);
state = PickupState.MoveToCarryable;
return this;
case PickupState.MoveToCarryable:
@@ -129,19 +135,14 @@ namespace OpenRA.Mods.Common.Activities
}
case PickupState.Wait:
state = PickupState.Pickup;
QueueChild(self, new Wait(delay, false), true);
state = PickupState.Pickup;
return this;
case PickupState.Pickup:
// Remove our carryable from world
Attach(self);
return NextActivity;
case PickupState.Aborted:
// We got cancelled
carryall.UnreserveCarryable(self);
break;
return this;
}
return NextActivity;