From 4a8571161a6ef3ad71f201b6c0c9356b6d424f77 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Apr 2017 21:13:02 +0200 Subject: [PATCH] Unhardcode LightPaletteRotator properties --- .../PaletteEffects/LightPaletteRotator.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/PaletteEffects/LightPaletteRotator.cs b/OpenRA.Mods.Cnc/Traits/PaletteEffects/LightPaletteRotator.cs index 14a72d7fb3..e6c80d8402 100644 --- a/OpenRA.Mods.Cnc/Traits/PaletteEffects/LightPaletteRotator.cs +++ b/OpenRA.Mods.Cnc/Traits/PaletteEffects/LightPaletteRotator.cs @@ -21,6 +21,15 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Palettes this effect should not apply to.")] public readonly HashSet ExcludePalettes = new HashSet(); + [Desc("'Speed' at which the effect cycles through palette indices.")] + public readonly float TimeStep = .5f; + + [Desc("Palette index to map to rotating color indices.")] + public readonly int ModifyIndex = 103; + + [Desc("Palette indices to rotate through.")] + public readonly int[] RotationIndices = { 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 238, 237, 236, 235, 234, 233, 232, 231 }; + public object Create(ActorInitializer init) { return new LightPaletteRotator(this); } } @@ -36,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Traits void ITick.Tick(Actor self) { - t += .5f; + t += info.TimeStep; } void IPaletteModifier.AdjustPalette(IReadOnlyDictionary palettes) @@ -46,11 +55,8 @@ namespace OpenRA.Mods.Cnc.Traits if (info.ExcludePalettes.Contains(pal.Key)) continue; - var rotate = (int)t % 18; - if (rotate > 9) - rotate = 18 - rotate; - - pal.Value.SetColor(0x67, pal.Value.GetColor(230 + rotate)); + var rotate = (int)t % info.RotationIndices.Length; + pal.Value.SetColor(info.ModifyIndex, pal.Value.GetColor(info.RotationIndices[rotate])); } } }