diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index 4d24f28d7c..e724273ee6 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Drawing; using System.Linq; using OpenRA.Mods.RA.Move; @@ -41,13 +42,13 @@ namespace OpenRA.Mods.RA public class Production { - RallyPoint rp; + Lazy rp; public ProductionInfo Info; public Production(ProductionInfo info, Actor self) { Info = info; - rp = self.TraitOrDefault(); + rp = Exts.Lazy(() => self.TraitOrDefault()); } public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo) @@ -82,15 +83,15 @@ namespace OpenRA.Mods.RA CPos MoveToRallyPoint(Actor self, Actor newUnit, CPos exitLocation) { - if (rp == null) + if (self.IsDead() || rp.Value == null) return exitLocation; var move = newUnit.TraitOrDefault(); if (move != null) { newUnit.QueueActivity(new AttackMove.AttackMoveActivity( - newUnit, move.MoveTo(rp.rallyPoint, rp.nearEnough))); - return rp.rallyPoint; + newUnit, move.MoveTo(rp.Value.rallyPoint, rp.Value.nearEnough))); + return rp.Value.rallyPoint; } return exitLocation;