undo problematic caching

This commit is contained in:
Chris Forbes
2010-03-18 13:33:43 +13:00
parent 8a05af72b3
commit 07b0c77db4
4 changed files with 18 additions and 21 deletions

View File

@@ -19,9 +19,9 @@
#endregion
using System;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits.Activities;
namespace OpenRA.Traits
{
@@ -161,5 +161,7 @@ namespace OpenRA.Traits
return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() }
.Where(w => w != null).Max(w => w.Range);
}
public static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2]); }
}
}

View File

@@ -37,6 +37,8 @@ namespace OpenRA.Traits
public readonly bool Playable = true;
public object Create(Actor self) { return new PlayerColorPalette(self, this); }
public Color Color { get { return Util.ArrayToColor(DisplayColor); } }
}
class PlayerColorPalette
@@ -46,17 +48,13 @@ namespace OpenRA.Traits
var wr = self.World.WorldRenderer;
var pal = wr.GetPalette(info.BasePalette);
var newpal = new Palette(pal, new PlayerColorRemap(
ArrayToColor(info.Color1),
ArrayToColor(info.Color2),
Util.ArrayToColor(info.Color1),
Util.ArrayToColor(info.Color2),
info.SplitRamp));
wr.AddPalette(info.Name, newpal);
if (info.Playable)
Player.RegisterPlayerColor(info.Name, info.DisplayName,
ArrayToColor(info.DisplayColor));
}
static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2]); }
}
}