Preserve original brightness when remapping player colors.

This commit is contained in:
Paul Chote
2021-04-10 18:12:50 +01:00
committed by teinarss
parent 9d62ce214c
commit 4042d5b179
5 changed files with 34 additions and 43 deletions

View File

@@ -40,16 +40,19 @@ namespace OpenRA.Mods.Common.Traits
"A dictionary of [faction name]: [actor name].")]
public readonly Dictionary<string, string> FactionPreviewActors = new Dictionary<string, string>();
[Desc("Remap these indices to player colors.")]
public readonly int[] RemapIndices = { };
public readonly float Ramp = 0.05f;
public Color Color { get; private set; }
public void Update(WorldRenderer worldRenderer, Color color)
{
Color = color;
Color.ToAhsv(out _, out var h, out var s, out _);
var newPalette = new MutablePalette(worldRenderer.Palette(PaletteName).Palette);
newPalette.ApplyRemap(new PlayerColorRemap(RemapIndices, Color, Ramp));
newPalette.ApplyRemap(new PlayerColorRemap(RemapIndices, h, s));
worldRenderer.ReplacePalette(PaletteName, newPalette);
}