From b497869993764fc8e888978bdc15b7670a71d6df Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 24 Apr 2016 18:51:26 +0200 Subject: [PATCH] Cache IMove in Repairable's ctor Instead of looking it up on every repair order. --- OpenRA.Mods.Common/Traits/Repairable.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index 403c6cebee..5f6d604644 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -20,7 +20,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor can be sent to a structure for repairs.")] - class RepairableInfo : ITraitInfo, Requires + class RepairableInfo : ITraitInfo, Requires, Requires { public readonly HashSet RepairBuildings = new HashSet { "fix" }; @@ -33,12 +33,14 @@ namespace OpenRA.Mods.Common.Traits { readonly RepairableInfo info; readonly Health health; + readonly IMove movement; readonly AmmoPool[] ammoPools; public Repairable(Actor self, RepairableInfo info) { this.info = info; health = self.Trait(); + movement = self.Trait(); ammoPools = self.TraitsImplementing().ToArray(); } @@ -90,7 +92,6 @@ namespace OpenRA.Mods.Common.Traits if (!CanRepairAt(order.TargetActor) || (!CanRepair() && !CanRearm())) return; - var movement = self.Trait(); var target = Target.FromOrder(self.World, order); self.SetTargetLine(target, Color.Green);