From dadc496c196e857ceff35a1e99b81731e93dc285 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 25 Apr 2012 21:43:00 +1200 Subject: [PATCH] beef up OpenRA.FileFormats.Set a little; use it in CncMenuPaletteEffect rather than making new List every frame --- OpenRA.FileFormats/Primitives/Set.cs | 10 +++++++++- OpenRA.Game/World.cs | 1 - OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenRA.FileFormats/Primitives/Set.cs b/OpenRA.FileFormats/Primitives/Set.cs index 99943a20db..d9017f6652 100755 --- a/OpenRA.FileFormats/Primitives/Set.cs +++ b/OpenRA.FileFormats/Primitives/Set.cs @@ -12,7 +12,7 @@ using System; using System.Collections; using System.Collections.Generic; -namespace OpenRA.Collections +namespace OpenRA.FileFormats { public class Set : IEnumerable { @@ -44,5 +44,13 @@ namespace OpenRA.Collections { return GetEnumerator(); } + + public bool Contains( T obj ) { return data.ContainsKey(obj); } + + public Set( params T[] ts ) + { + foreach( var t in ts ) + Add(t); + } } } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 4efb2f4382..e2ec53704c 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -11,7 +11,6 @@ using System; using System.Collections.Generic; using System.Linq; -using OpenRA.Collections; using OpenRA.Effects; using OpenRA.FileFormats; using OpenRA.Network; diff --git a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs index bed2867125..df198b1430 100644 --- a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs +++ b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs @@ -61,12 +61,13 @@ namespace OpenRA.Mods.Cnc } } + static Set excludePalettes = new Set("cursor", "chrome", "colorpicker", "shroud", "fog"); + public void AdjustPalette(Dictionary palettes) { if (to == EffectType.None && remainingFrames == 0) return; - var excludePalettes = new List(){"cursor", "chrome", "colorpicker", "shroud", "fog"}; foreach (var pal in palettes) { if (excludePalettes.Contains(pal.Key))