diff --git a/OpenRA.Mods.D2k/Activities/DeliverUnit.cs b/OpenRA.Mods.D2k/Activities/DeliverUnit.cs index 0b3fe70817..b707a59dda 100644 --- a/OpenRA.Mods.D2k/Activities/DeliverUnit.cs +++ b/OpenRA.Mods.D2k/Activities/DeliverUnit.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.D2k.Activities readonly IFacing cargoFacing; readonly IFacing selfFacing; - enum State { Transport, Land, Release, Done } + enum State { Transport, Land, Release } State state; @@ -108,11 +108,6 @@ namespace OpenRA.Mods.D2k.Activities } Release(); - state = State.Done; - return Util.SequenceActivities(new Wait(10), this); - - case State.Done: - self.Trait().UnreserveCarryable(); return NextActivity; } @@ -125,7 +120,11 @@ namespace OpenRA.Mods.D2k.Activities cargoFacing.Facing = selfFacing.Facing; // Put back into world - self.World.AddFrameEndTask(w => cargo.World.Add(cargo)); + self.World.AddFrameEndTask(w => + { + cargo.World.Add(cargo); + carryall.UnreserveCarryable(); + }); // Unlock carryable carryall.CarryableReleased(); diff --git a/OpenRA.Mods.D2k/Traits/Buildings/FreeActorWithDelivery.cs b/OpenRA.Mods.D2k/Traits/Buildings/FreeActorWithDelivery.cs index fd9f57ee65..8ccafdefce 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/FreeActorWithDelivery.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/FreeActorWithDelivery.cs @@ -64,7 +64,9 @@ namespace OpenRA.Mods.D2k.Traits if (clientInitialActivity != null) cargo.QueueActivity(Game.CreateObject(clientInitialActivity)); - cargo.Trait().Destination = location; + var carryable = cargo.Trait(); + carryable.Destination = location; + carryable.Reserve(carrier); carrier.Trait().AttachCarryable(cargo); diff --git a/OpenRA.Mods.D2k/Traits/Carryable.cs b/OpenRA.Mods.D2k/Traits/Carryable.cs index 1cb17c5cc9..2e577f1627 100644 --- a/OpenRA.Mods.D2k/Traits/Carryable.cs +++ b/OpenRA.Mods.D2k/Traits/Carryable.cs @@ -116,6 +116,9 @@ namespace OpenRA.Mods.D2k.Traits public bool Reserve(Actor carrier) { + if (Reserved) + return false; + if ((self.Location - Destination).Length < info.MinDistance) { MovementCancelled(self); diff --git a/OpenRA.Mods.D2k/Traits/Carryall.cs b/OpenRA.Mods.D2k/Traits/Carryall.cs index 94f7d486b9..f40c622f12 100644 --- a/OpenRA.Mods.D2k/Traits/Carryall.cs +++ b/OpenRA.Mods.D2k/Traits/Carryall.cs @@ -122,6 +122,9 @@ namespace OpenRA.Mods.D2k.Traits // Reserve the carryable so its ours exclusively public bool ReserveCarryable(Actor carryable) { + if (Carrying != null) + return false; + if (carryable.Trait().Reserve(self)) { Carrying = carryable; @@ -144,6 +147,7 @@ namespace OpenRA.Mods.D2k.Traits } IsBusy = false; + Carrying = null; } // INotifyKilled @@ -177,6 +181,7 @@ namespace OpenRA.Mods.D2k.Traits // Called when released public void CarryableReleased() { + IsBusy = false; IsCarrying = false; anim = null; }