diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index e9c926c62b..f621703e71 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits } public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled, - INotifyOwnerChanged, ITick, INotifySold, INotifyActorDisposing, IIssueDeployOrder, + INotifyOwnerChanged, INotifySold, INotifyActorDisposing, IIssueDeployOrder, ITransformActorInitModifier { public readonly CargoInfo Info; @@ -161,6 +161,17 @@ namespace OpenRA.Mods.Common.Traits totalWeight = cargo.Sum(c => GetWeight(c)); } + foreach (var c in cargo) + { + c.Trait().Transport = self; + + foreach (var nec in c.TraitsImplementing()) + nec.OnEnteredCargo(c, self); + + foreach (var npe in self.TraitsImplementing()) + npe.OnPassengerEntered(self, c); + } + facing = Exts.Lazy(self.TraitOrDefault); } @@ -408,15 +419,11 @@ namespace OpenRA.Mods.Common.Traits loadingToken = conditionManager.RevokeCondition(self, loadingToken); } - // If not initialized then this will be notified in the first tick - if (initialized) - { - foreach (var nec in a.TraitsImplementing()) - nec.OnEnteredCargo(a, self); + foreach (var nec in a.TraitsImplementing()) + nec.OnEnteredCargo(a, self); - foreach (var npe in self.TraitsImplementing()) - npe.OnPassengerEntered(self, a); - } + foreach (var npe in self.TraitsImplementing()) + npe.OnPassengerEntered(self, a); var p = a.Trait(); p.Transport = self; @@ -495,27 +502,6 @@ namespace OpenRA.Mods.Common.Traits p.ChangeOwner(newOwner); } - bool initialized; - void ITick.Tick(Actor self) - { - // Notify initial cargo load - if (!initialized) - { - foreach (var c in cargo) - { - c.Trait().Transport = self; - - foreach (var nec in c.TraitsImplementing()) - nec.OnEnteredCargo(c, self); - - foreach (var npe in self.TraitsImplementing()) - npe.OnPassengerEntered(self, c); - } - - initialized = true; - } - } - void ITransformActorInitModifier.ModifyTransformActorInit(Actor self, TypeDictionary init) { init.Add(new RuntimeCargoInit(Passengers.ToArray()));