diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 4ce3d7d8c4..df65ce57c7 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -79,6 +79,7 @@ namespace OpenRa.Game var worldActor = new Actor(null, new int2(int.MaxValue, int.MaxValue), null); worldActor.traits.Add(new Traits.WaterPaletteRotation(worldActor)); + worldActor.traits.Add(new Traits.LightPaletteRotator(worldActor)); worldActor.traits.Add(new Traits.ChronoshiftPaletteEffect(worldActor)); Game.world.Add(worldActor); diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index aac3bc8b21..14c7838ece 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -234,6 +234,7 @@ + diff --git a/OpenRa.Game/Traits/LightPaletteRotator.cs b/OpenRa.Game/Traits/LightPaletteRotator.cs new file mode 100644 index 0000000000..65ed5c59d7 --- /dev/null +++ b/OpenRa.Game/Traits/LightPaletteRotator.cs @@ -0,0 +1,26 @@ +using System.Drawing; + +namespace OpenRa.Game.Traits +{ + class LightPaletteRotator : ITick, IPaletteModifier + { + public LightPaletteRotator(Actor self) { } + + float t = 0; + public void Tick(Actor self) + { + t += .5f; + } + + public void AdjustPalette(Bitmap b) + { + var rotate = (int)t % 18; + if (rotate > 9) + rotate = 18 - rotate; + + using (var bitmapCopy = new Bitmap(b)) + for (int j = 0; j < 16; j++) + b.SetPixel(0x67, j, b.GetPixel(230+rotate, j)); + } + } +}