From df94f0ec8bad959c9f0c0c3988c4081e62122fad Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Wed, 20 Jan 2021 17:16:19 +0300 Subject: [PATCH] Add InitialActor to Carryall. --- OpenRA.Mods.Common/Traits/Carryall.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Carryall.cs b/OpenRA.Mods.Common/Traits/Carryall.cs index e5795e167f..2302de181a 100644 --- a/OpenRA.Mods.Common/Traits/Carryall.cs +++ b/OpenRA.Mods.Common/Traits/Carryall.cs @@ -23,6 +23,10 @@ namespace OpenRA.Mods.Common.Traits [Desc("Transports actors with the `Carryable` trait.")] public class CarryallInfo : TraitInfo, Requires, Requires { + [ActorReference(typeof(CarryableInfo))] + [Desc("Actor type that is initially spawned into this actor.")] + public readonly string InitialActor = null; + [Desc("Delay (in ticks) on the ground while attaching an actor to the carryall.")] public readonly int BeforeLoadDelay = 0; @@ -110,6 +114,18 @@ namespace OpenRA.Mods.Common.Traits move = self.Trait(); facing = self.Trait(); this.self = self; + + if (!string.IsNullOrEmpty(info.InitialActor)) + { + var unit = self.World.CreateActor(false, info.InitialActor.ToLowerInvariant(), new TypeDictionary + { + new ParentActorInit(self), + new OwnerInit(self.Owner) + }); + + unit.Trait().Attached(self); + AttachCarryable(self, unit); + } } void ITick.Tick(Actor self)