From 7e9a3d3bc942641e1b46644df80ed5098c99f2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 2 Jan 2020 17:35:48 +0100 Subject: [PATCH] Unhardcode transparent index in manual palettes as well. --- OpenRA.Mods.Common/Traits/World/PaletteFromRGBA.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/World/PaletteFromRGBA.cs b/OpenRA.Mods.Common/Traits/World/PaletteFromRGBA.cs index 580f61d803..b52d3222aa 100644 --- a/OpenRA.Mods.Common/Traits/World/PaletteFromRGBA.cs +++ b/OpenRA.Mods.Common/Traits/World/PaletteFromRGBA.cs @@ -41,6 +41,9 @@ namespace OpenRA.Mods.Common.Traits public readonly bool AllowModifiers = true; + [Desc("Index set to be fully transparent/invisible.")] + public readonly int TransparentIndex = 0; + public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.World, this); } } @@ -65,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits var g = (int)(a * info.G + 0.5f).Clamp(0, 255); var b = (int)(a * info.B + 0.5f).Clamp(0, 255); var c = (uint)Color.FromArgb(info.A, r, g, b).ToArgb(); - wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (i == 0) ? 0 : c)), info.AllowModifiers); + wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (i == info.TransparentIndex) ? 0 : c)), info.AllowModifiers); } } }