Cache traits implementing INotifyBurstComplete

This commit is contained in:
reaperrr
2017-06-17 21:59:18 +02:00
committed by atlimit8
parent 100abe3246
commit 243ed3d76a

View File

@@ -107,6 +107,7 @@ namespace OpenRA.Mods.Common.Traits
Turreted turret;
AmmoPool ammoPool;
BodyOrientation coords;
INotifyBurstComplete[] notifyBurstComplete;
IEnumerable<int> rangeModifiers;
List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();
@@ -149,6 +150,7 @@ namespace OpenRA.Mods.Common.Traits
turret = self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == Info.Turret);
ammoPool = self.TraitsImplementing<AmmoPool>().FirstOrDefault(la => la.Info.Name == Info.AmmoPoolName);
coords = self.Trait<BodyOrientation>();
notifyBurstComplete = self.TraitsImplementing<INotifyBurstComplete>().ToArray();
rangeModifiers = self.TraitsImplementing<IRangeModifier>().ToArray().Select(m => m.GetRangeModifier());
base.Created(self);
@@ -281,7 +283,7 @@ namespace OpenRA.Mods.Common.Traits
});
}
foreach (var nbc in self.TraitsImplementing<INotifyBurstComplete>())
foreach (var nbc in notifyBurstComplete)
nbc.FiredBurst(self, target, this);
}