From dd88a1269a230d17b72c1cb401277d63e921e9f9 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 27 Dec 2011 14:52:11 +1300 Subject: [PATCH] move MakeArray to FileFormats.Exts --- OpenRA.FileFormats/Exts.cs | 9 +++++++++ OpenRA.Game/Graphics/Util.cs | 9 --------- OpenRA.Game/WorldUtils.cs | 2 +- OpenRA.Mods.RA/LimitedAmmo.cs | 2 +- OpenRA.Mods.RA/StoresOre.cs | 2 +- OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs | 2 +- OpenRA.Utility/Command.cs | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/OpenRA.FileFormats/Exts.cs b/OpenRA.FileFormats/Exts.cs index affb235edc..65a05b8423 100755 --- a/OpenRA.FileFormats/Exts.cs +++ b/OpenRA.FileFormats/Exts.cs @@ -190,6 +190,15 @@ namespace OpenRA (int)(t * c2.G + (1 - t) * c1.G), (int)(t * c2.B + (1 - t) * c1.B)); } + + public static T[] MakeArray(int count, Func f) + { + T[] result = new T[count]; + for (int i = 0; i < count; i++) + result[i] = f(i); + + return result; + } } public static class Enum diff --git a/OpenRA.Game/Graphics/Util.cs b/OpenRA.Game/Graphics/Util.cs index 9d2cab089c..5d4f27c71a 100644 --- a/OpenRA.Game/Graphics/Util.cs +++ b/OpenRA.Game/Graphics/Util.cs @@ -19,15 +19,6 @@ namespace OpenRA.Graphics { public static class Util { - public static T[] MakeArray(int count, Func f) - { - T[] result = new T[count]; - for (int i = 0; i < count; i++) - result[i] = f(i); - - return result; - } - static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f }; public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, int palette, int nv, float2 size) diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 3422fe0eba..faa127316a 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -104,7 +104,7 @@ namespace OpenRA public static float Gauss1D(this Thirdparty.Random r, int samples) { - return Graphics.Util.MakeArray(samples, _ => (float)r.NextDouble() * 2 - 1f) + return Exts.MakeArray(samples, _ => (float)r.NextDouble() * 2 - 1f) .Sum() / samples; } diff --git a/OpenRA.Mods.RA/LimitedAmmo.cs b/OpenRA.Mods.RA/LimitedAmmo.cs index 38e0209e68..02df6181d5 100644 --- a/OpenRA.Mods.RA/LimitedAmmo.cs +++ b/OpenRA.Mods.RA/LimitedAmmo.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA public IEnumerable GetPips(Actor self) { var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo; - return Graphics.Util.MakeArray(pips, + return Exts.MakeArray(pips, i => (ammo * pips) / Info.Ammo > i ? PipType.Green : PipType.Transparent); } } diff --git a/OpenRA.Mods.RA/StoresOre.cs b/OpenRA.Mods.RA/StoresOre.cs index aa474bfce8..ece2241db1 100644 --- a/OpenRA.Mods.RA/StoresOre.cs +++ b/OpenRA.Mods.RA/StoresOre.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA public IEnumerable GetPips(Actor self) { - return Graphics.Util.MakeArray( Info.PipCount, + return Exts.MakeArray( Info.PipCount, i => ( Player.Ore * Info.PipCount > i * Player.OreCapacity ) ? Info.PipColor : PipType.Transparent ); } diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index 16a937cadd..80f574f9f0 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - var options = Graphics.Util.MakeArray(map.GetSpawnPoints().Length + 1, i => i).ToList(); + var options = Exts.MakeArray(map.GetSpawnPoints().Length + 1, i => i).ToList(); dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem); } diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index c3bcc040f8..dfa3e8f71c 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -201,7 +201,7 @@ namespace OpenRA.Utility var srcPalette = Palette.Load(args[1].Split(':')[1], false); var destPalette = Palette.Load(args[2].Split(':')[1], false); - var fullIndexRange = OpenRA.Graphics.Util.MakeArray(256, x => x); + var fullIndexRange = Exts.MakeArray(256, x => x); for( var i = 0; i < 256; i++ ) if (!remap.ContainsKey(i))