Make Color use uint for ARGB.
This is a more natural representation than int that allows removal of casts in many places that require uint. Additionally, we can change the internal representation from long to uint, making the Color struct smaller. Since arrays of colors are common, this can save on memory.
This commit is contained in:
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
readonly World world;
|
||||
IRadarTerrainLayer[] radarTerrainLayers;
|
||||
CellLayer<(int, int)> terrainColor;
|
||||
CellLayer<(uint, uint)> terrainColor;
|
||||
readonly Shroud shroud;
|
||||
|
||||
public event Action<MPos> CellTerrainColorChanged = null;
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
radarTerrainLayers = w.WorldActor.TraitsImplementing<IRadarTerrainLayer>().ToArray();
|
||||
terrainColor = new CellLayer<(int, int)>(w.Map);
|
||||
terrainColor = new CellLayer<(uint, uint)>(w.Map);
|
||||
|
||||
w.AddFrameEndTask(_ =>
|
||||
{
|
||||
@@ -82,9 +82,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
}
|
||||
|
||||
public (int Left, int Right) this[MPos uv] => terrainColor[uv];
|
||||
public (uint Left, uint Right) this[MPos uv] => terrainColor[uv];
|
||||
|
||||
public static (int Left, int Right) GetColor(Map map, IRadarTerrainLayer[] radarTerrainLayers, MPos uv)
|
||||
public static (uint Left, uint Right) GetColor(Map map, IRadarTerrainLayer[] radarTerrainLayers, MPos uv)
|
||||
{
|
||||
foreach (var rtl in radarTerrainLayers)
|
||||
if (rtl.TryGetTerrainColorPair(uv, out var c))
|
||||
|
||||
Reference in New Issue
Block a user