Unhardcode LightPaletteRotator properties
This commit is contained in:
@@ -21,6 +21,15 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("Palettes this effect should not apply to.")]
|
||||
public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
|
||||
|
||||
[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<string, MutablePalette> 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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user