From 3e5155fa7dd871efc02c515c797d650692fb621a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 3 Jul 2016 14:40:14 +0200 Subject: [PATCH] Cache pipImages in the constructor. --- OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs index b4e3d5776d..a9510414aa 100644 --- a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs +++ b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs @@ -50,12 +50,16 @@ namespace OpenRA.Mods.Common.Traits.Render static readonly string[] PipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" }; public readonly SelectionDecorationsInfo Info; + readonly Actor self; + readonly Animation pipImages; public SelectionDecorations(Actor self, SelectionDecorationsInfo info) { this.self = self; Info = info; + + pipImages = new Animation(self.World, Info.Image); } IEnumerable ActivityTargetPath() @@ -109,7 +113,6 @@ namespace OpenRA.Mods.Common.Traits.Render if (group == null) yield break; - var pipImages = new Animation(self.World, Info.Image); var pal = wr.Palette(Info.Palette); pipImages.PlayFetchIndex(Info.GroupSequence, () => (int)group); pipImages.Tick(); @@ -124,7 +127,6 @@ namespace OpenRA.Mods.Common.Traits.Render if (!pipSources.Any()) yield break; - var pipImages = new Animation(self.World, Info.Image); pipImages.PlayRepeating(PipStrings[0]); var pipSize = pipImages.Image.Size.XY.ToInt2();