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

@@ -6,12 +6,12 @@
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Drawing;
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits;
using System.Collections.Generic;
using OpenRA.FileFormats;
namespace OpenRA.Mods.RA
{
@@ -22,20 +22,26 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self)
{
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();
continue;
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]);
}
}
}