From f7c344bef8646d290e99248cb0ab9f59c1200788 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 4 Oct 2014 23:15:42 +1300 Subject: [PATCH] Query Turreted trait dependencies using INotifyCreated. Fixes #6655. --- OpenRA.Mods.RA/Turreted.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.RA/Turreted.cs b/OpenRA.Mods.RA/Turreted.cs index 8e46f0b6fc..42735f816c 100755 --- a/OpenRA.Mods.RA/Turreted.cs +++ b/OpenRA.Mods.RA/Turreted.cs @@ -29,14 +29,15 @@ namespace OpenRA.Mods.RA public virtual object Create(ActorInitializer init) { return new Turreted(init, this); } } - public class Turreted : ITick, ISync + public class Turreted : ITick, ISync, INotifyCreated { + readonly TurretedInfo info; + AttackTurreted attack; + IFacing facing; + [Sync] public int QuantizedFacings = 0; [Sync] public int turretFacing = 0; public int? desiredFacing; - TurretedInfo info; - IFacing facing; - Lazy attack; int realignTick = 0; // For subclasses that want to move the turret relative to the body @@ -60,13 +61,17 @@ namespace OpenRA.Mods.RA { this.info = info; turretFacing = GetInitialTurretFacing(init, info.InitialFacing); - facing = init.self.TraitOrDefault(); - attack = Exts.Lazy(() => init.self.TraitOrDefault()); + } + + public void Created(Actor self) + { + attack = self.TraitOrDefault(); + facing = self.TraitOrDefault(); } public virtual void Tick(Actor self) { - if (attack.Value != null && !attack.Value.IsAttacking) + if (attack != null && !attack.IsAttacking) { if (realignTick < info.RealignDelay) realignTick++;