From d3959d21caa781503d02c0bac7e55cf23a73aae5 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 15 Apr 2013 00:10:07 +1200 Subject: [PATCH] Add a ParentActorInit for FreeActor spawns. --- OpenRA.Mods.RA/FreeActor.cs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/OpenRA.Mods.RA/FreeActor.cs b/OpenRA.Mods.RA/FreeActor.cs index cab41feb88..fb5199e333 100644 --- a/OpenRA.Mods.RA/FreeActor.cs +++ b/OpenRA.Mods.RA/FreeActor.cs @@ -34,21 +34,22 @@ namespace OpenRA.Mods.RA { public FreeActor(ActorInitializer init, FreeActorInfo info) { - if (init.Contains() && !init.Get().value) return; + if (init.Contains() && !init.Get().value) + return; - init.self.World.AddFrameEndTask( - w => + init.self.World.AddFrameEndTask(w => + { + var a = w.CreateActor(info.Actor, new TypeDictionary { - var a = w.CreateActor(info.Actor, new TypeDictionary - { - new LocationInit( init.self.Location + (CVec)info.SpawnOffset ), - new OwnerInit( init.self.Owner ), - new FacingInit( info.Facing ), - }); - - if (info.InitialActivity != null) - a.QueueActivity(Game.CreateObject(info.InitialActivity)); + new ParentActorInit(init.self), + new LocationInit(init.self.Location + (CVec)info.SpawnOffset), + new OwnerInit(init.self.Owner), + new FacingInit(info.Facing), }); + + if (info.InitialActivity != null) + a.QueueActivity(Game.CreateObject(info.InitialActivity)); + }); } } @@ -60,4 +61,11 @@ namespace OpenRA.Mods.RA public FreeActorInit(bool init) { value = init; } public bool Value(World world) { return value; } } + + public class ParentActorInit : IActorInit + { + public readonly Actor value; + public ParentActorInit(Actor parent) { value = parent; } + public Actor Value(World world) { return value; } + } }