PlayerColorPalette now using the full palette if no RemapIndex is set.

This commit is contained in:
Andre Mohren
2022-05-26 10:58:26 +02:00
committed by Gustas
parent df72d303b8
commit 0e5f33ef93
7 changed files with 18 additions and 13 deletions

View File

@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Primitives;
using OpenRA.Traits;
@@ -31,7 +32,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The name of the palette to base off.")]
public readonly string BasePalette = null;
[FieldLoader.Require]
[Desc("Remap these indices to player colors.")]
public readonly int[] RemapIndex = Array.Empty<int>();
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
{
color = colorManager.Color;
var (_, h, s, _) = color.ToAhsv();
var remap = new PlayerColorRemap(info.RemapIndex, h, s);
var remap = new PlayerColorRemap(info.RemapIndex.Length == 0 ? Enumerable.Range(0, 256).ToArray() : info.RemapIndex, h, s);
wr.AddPalette(info.Name, new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers);
}
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
color = colorManager.Color;
var (_, h, s, _) = color.ToAhsv();
var remap = new PlayerColorRemap(info.RemapIndex, h, s);
var remap = new PlayerColorRemap(info.RemapIndex.Length == 0 ? Enumerable.Range(0, 256).ToArray() : info.RemapIndex, h, s);
wr.ReplacePalette(info.Name, new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap));
}
}