diff --git a/OpenRA.Mods.Common/Activities/Transform.cs b/OpenRA.Mods.Common/Activities/Transform.cs index 5ca5066023..245a0fd83d 100644 --- a/OpenRA.Mods.Common/Activities/Transform.cs +++ b/OpenRA.Mods.Common/Activities/Transform.cs @@ -127,9 +127,8 @@ namespace OpenRA.Mods.Common.Activities init.Add(new HealthInit(newHP)); } - var cargo = self.TraitOrDefault(); - if (cargo != null) - init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray())); + foreach (var modifier in self.TraitsImplementing()) + modifier.ModifyTransformActorInit(self, init); var a = w.CreateActor(ToActor, init); foreach (var nt in self.TraitsImplementing()) diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index 79aa9ae21b..1b5591f222 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -75,7 +75,8 @@ namespace OpenRA.Mods.Common.Traits } public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled, - INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing, IIssueDeployOrder + INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing, IIssueDeployOrder, + ITransformActorInitModifier { public readonly CargoInfo Info; readonly Actor self; @@ -469,6 +470,11 @@ namespace OpenRA.Mods.Common.Traits CurrentAdjacentCells = GetAdjacentCells(); } } + + void ITransformActorInitModifier.ModifyTransformActorInit(Actor self, TypeDictionary init) + { + init.Add(new RuntimeCargoInit(Passengers.ToArray())); + } } public class RuntimeCargoInit : IActorInit, ISuppressInitExport diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 7d52ab4734..6af71814c0 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -280,6 +280,11 @@ namespace OpenRA.Mods.Common.Traits void ModifyDeathActorInit(Actor self, TypeDictionary init); } + public interface ITransformActorInitModifier + { + void ModifyTransformActorInit(Actor self, TypeDictionary init); + } + public interface IPreventsAutoTarget { bool PreventsAutoTarget(Actor self, Actor attacker);