undo problematic caching
This commit is contained in:
@@ -102,7 +102,6 @@ namespace OpenRA
|
||||
|
||||
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
||||
|
||||
Player.ResetPlayerColorList();
|
||||
ChromeProvider.Initialize(manifest.Chrome);
|
||||
|
||||
world = new World();
|
||||
|
||||
@@ -49,22 +49,20 @@ namespace OpenRA
|
||||
public int PowerProvided = 0;
|
||||
public int PowerDrained = 0;
|
||||
|
||||
public Shroud Shroud;
|
||||
|
||||
public World World { get { return PlayerActor.World; } }
|
||||
|
||||
public static List<Tuple<string, string, Color>> PlayerColors = new List<Tuple<string, string, Color>>();
|
||||
public static void ResetPlayerColorList()
|
||||
public static List<Tuple<string, string, Color>> PlayerColors
|
||||
{
|
||||
// This is unsafe if the mapchange introduces/removes mods that defines new colors
|
||||
// TODO: ensure that each player's palette index is reassigned appropriately
|
||||
PlayerColors = new List<Tuple<string, string, Color>>();
|
||||
}
|
||||
|
||||
public static void RegisterPlayerColor(string palette, string name, Color c)
|
||||
get
|
||||
{
|
||||
PlayerColors.Add(new Tuple<string, string, Color>(palette, name, c));
|
||||
return Game.world.WorldActor.Info.Traits.WithInterface<PlayerColorPaletteInfo>()
|
||||
.Where(p => p.Playable)
|
||||
.Select(p => Tuple.New(p.Name, p.DisplayName, p.Color))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public Shroud Shroud;
|
||||
|
||||
public Player( World world, Session.Client client )
|
||||
{
|
||||
|
||||
@@ -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]); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user