diff --git a/OpenRA.Mods.Common/Traits/Carryall.cs b/OpenRA.Mods.Common/Traits/Carryall.cs index 1c8a0272b2..4f53b0f27e 100644 --- a/OpenRA.Mods.Common/Traits/Carryall.cs +++ b/OpenRA.Mods.Common/Traits/Carryall.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits public virtual object Create(ActorInitializer init) { return new Carryall(init.Self, this); } } - public class Carryall : INotifyKilled, ISync, IRender, INotifyActorDisposing, IIssueOrder, IResolveOrder, IOrderVoice + public class Carryall : INotifyKilled, ISync, ITick, IRender, INotifyActorDisposing, IIssueOrder, IResolveOrder, IOrderVoice { public enum CarryallState { @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits public Carryall(Actor self, CarryallInfo info) { - this.Info = info; + Info = info; Carryable = null; State = CarryallState.Idle; @@ -79,6 +79,13 @@ namespace OpenRA.Mods.Common.Traits facing = self.Trait(); } + void ITick.Tick(Actor self) + { + // Cargo may be killed in the same tick as, but after they are attached + if (Carryable != null && Carryable.IsDead) + DetachCarryable(self); + } + void INotifyActorDisposing.Disposing(Actor self) { if (State == CarryallState.Carrying) @@ -156,7 +163,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable IRender.Render(Actor self, WorldRenderer wr) { - if (State == CarryallState.Carrying) + if (State == CarryallState.Carrying && !Carryable.IsDead) { if (carryablePreview == null) {