Skip to content

Commit

Permalink
Add InitialActor to Carryall.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR authored and pchote committed Feb 14, 2021
1 parent 9ee7294 commit df94f0e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions OpenRA.Mods.Common/Traits/Carryall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Transports actors with the `Carryable` trait.")]
public class CarryallInfo : TraitInfo, Requires<BodyOrientationInfo>, Requires<AircraftInfo>
{
[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;

Expand Down Expand Up @@ -110,6 +114,18 @@ public Carryall(Actor self, CarryallInfo info)
move = self.Trait<IMove>();
facing = self.Trait<IFacing>();
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<Carryable>().Attached(self);
AttachCarryable(self, unit);
}
}

void ITick.Tick(Actor self)
Expand Down

0 comments on commit df94f0e

Please sign in to comment.