From 4c50757b1817a56e90f10593e9a5e6f041f2384d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 27 May 2014 17:14:05 +0200 Subject: [PATCH] catch trait lookup in constructor closes #5472 --- OpenRA.Mods.Cnc/ProductionAirdrop.cs | 6 +++--- OpenRA.Mods.RA/Production.cs | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Cnc/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/ProductionAirdrop.cs index 39bbfd6f54..61db327831 100644 --- a/OpenRA.Mods.Cnc/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/ProductionAirdrop.cs @@ -25,13 +25,13 @@ namespace OpenRA.Mods.Cnc [Desc("Cargo aircraft used.")] [ActorReference] public readonly string ActorType = "c17"; - public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); } + public override object Create(ActorInitializer init) { return new ProductionAirdrop(this, init.self); } } class ProductionAirdrop : Production { - public ProductionAirdrop(ProductionAirdropInfo info) - : base(info) { } + public ProductionAirdrop(ProductionAirdropInfo info, Actor self) + : base(info, self) { } public override bool Produce(Actor self, ActorInfo producee) { diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index 8a03489bec..4d24f28d7c 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA [Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")] public readonly string[] Produces = { }; - public virtual object Create(ActorInitializer init) { return new Production(this); } + public virtual object Create(ActorInitializer init) { return new Production(this, init.self); } } [Desc("Where the unit should leave the building. Multiples are allowed if IDs are added: Exit@2, ...")] @@ -41,10 +41,13 @@ namespace OpenRA.Mods.RA public class Production { + RallyPoint rp; + public ProductionInfo Info; - public Production(ProductionInfo info) + public Production(ProductionInfo info, Actor self) { Info = info; + rp = self.TraitOrDefault(); } public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo) @@ -77,9 +80,8 @@ namespace OpenRA.Mods.RA }); } - static CPos MoveToRallyPoint(Actor self, Actor newUnit, CPos exitLocation) + CPos MoveToRallyPoint(Actor self, Actor newUnit, CPos exitLocation) { - var rp = self.TraitOrDefault(); if (rp == null) return exitLocation;