strip all the allocation out of WaterPaletteRotation too (saves ~25M/min)

This commit is contained in:
Chris Forbes
2011-03-05 18:34:52 +13:00
parent c1ad99bb99
commit 03bda8b511

View File

@@ -8,10 +8,10 @@
*/
#endregion
using System.Drawing;
using OpenRA.Traits;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
@@ -24,18 +24,24 @@ namespace OpenRA.Mods.RA
t += .25f;
}
static string[] excludePalettes = { "cursor", "chrome", "colorpicker" };
static uint[] temp = new uint[7];
public void AdjustPalette(Dictionary<string,Palette> palettes)
{
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker"};
foreach (var pal in palettes)
{
if (excludePalettes.Contains(pal.Key))
continue;
var copy = (uint[])pal.Value.Values.Clone();
var colors = pal.Value.Values;
var rotate = (int)t % 7;
for (int i = 0; i < 7; i++)
pal.Value.SetColor(0x60 + (rotate + i) % 7, copy[0x60 + i]);
for (var i = 0; i < 7; i++)
temp[(rotate + i) % 7] = colors[0x60 + i];
for (var i = 0; i < 7; i++)
pal.Value.SetColor(0x60 + i, temp[i]);
}
}
}