diff --git a/OpenRA.FileFormats/Map/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs index 0c835e14cc..985ef1e2e2 100644 --- a/OpenRA.FileFormats/Map/TileSet.cs +++ b/OpenRA.FileFormats/Map/TileSet.cs @@ -80,6 +80,7 @@ namespace OpenRA.FileFormats public string Palette; public int TileSize = 24; public string[] Extensions; + public int WaterPaletteRotationBase = 0x60; public Dictionary Terrain = new Dictionary(); public Dictionary Templates = new Dictionary(); diff --git a/OpenRA.Mods.RA/WaterPaletteRotation.cs b/OpenRA.Mods.RA/WaterPaletteRotation.cs index b19233e777..d8aa3e4d6b 100644 --- a/OpenRA.Mods.RA/WaterPaletteRotation.cs +++ b/OpenRA.Mods.RA/WaterPaletteRotation.cs @@ -17,38 +17,43 @@ namespace OpenRA.Mods.RA { class WaterPaletteRotationInfo : ITraitInfo { - public readonly int Base = 0x60; + public readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker" }; - public object Create(ActorInitializer init) { return new WaterPaletteRotation(this); } + public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); } } class WaterPaletteRotation : ITick, IPaletteModifier { float t = 0; - readonly WaterPaletteRotationInfo info; - public WaterPaletteRotation(WaterPaletteRotationInfo info) { this.info = info; } + readonly WaterPaletteRotationInfo info; + readonly World world; + + public WaterPaletteRotation(World world, WaterPaletteRotationInfo info) + { + this.world = world; + this.info = info; + } public void Tick(Actor self) { t += .25f; } - static string[] excludePalettes = { "cursor", "chrome", "colorpicker" }; static uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */ public void AdjustPalette(Dictionary palettes) { foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) + if (info.ExcludePalettes.Contains(pal.Key)) continue; var colors = pal.Value.Values; var rotate = (int)t % 7; for (var i = 0; i < 7; i++) - temp[(rotate + i) % 7] = colors[info.Base + i]; + temp[(rotate + i) % 7] = colors[world.TileSet.WaterPaletteRotationBase + i]; for (var i = 0; i < 7; i++) - pal.Value.SetColor(info.Base + i, temp[i]); + pal.Value.SetColor(world.TileSet.WaterPaletteRotationBase + i, temp[i]); } } } diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 1b5424fe86..1e58cb604a 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -62,7 +62,6 @@ World: ScreenShaker: NukePaletteEffect: WaterPaletteRotation: - Base: 32 BuildingInfluence: BridgeLayer: Bridges: bridge1, bridge2, bridge3, bridge4 diff --git a/mods/cnc/tilesets/desert.yaml b/mods/cnc/tilesets/desert.yaml index 880e59b9e4..cde9f0a7e8 100644 --- a/mods/cnc/tilesets/desert.yaml +++ b/mods/cnc/tilesets/desert.yaml @@ -2,7 +2,8 @@ General: Name: Desert Id: DESERT Extensions: .des, .shp, .tem - Palette: desert.pal + Palette: desert.pal + WaterPaletteRotationBase: 32 Terrain: TerrainType@Clear: diff --git a/mods/cnc/tilesets/snow.yaml b/mods/cnc/tilesets/snow.yaml index c7c3965b4e..4a8d24886f 100644 --- a/mods/cnc/tilesets/snow.yaml +++ b/mods/cnc/tilesets/snow.yaml @@ -3,6 +3,7 @@ General: Id: SNOW Extensions: .sno, .shp, .tem Palette: snow.pal + WaterPaletteRotationBase: 32 Terrain: TerrainType@Clear: diff --git a/mods/cnc/tilesets/temperat.yaml b/mods/cnc/tilesets/temperat.yaml index d55ffc868e..7dbe8c3528 100644 --- a/mods/cnc/tilesets/temperat.yaml +++ b/mods/cnc/tilesets/temperat.yaml @@ -3,6 +3,7 @@ General: Id: TEMPERAT Extensions: .tem, .shp Palette: temperat.pal + WaterPaletteRotationBase: 32 Terrain: TerrainType@Clear: diff --git a/mods/cnc/tilesets/winter.yaml b/mods/cnc/tilesets/winter.yaml index e0d8288c05..b3b3ab2b29 100644 --- a/mods/cnc/tilesets/winter.yaml +++ b/mods/cnc/tilesets/winter.yaml @@ -2,7 +2,8 @@ General: Name: Winter Id: WINTER Extensions: .win, .shp, .tem - Palette: winter.pal + Palette: winter.pal + WaterPaletteRotationBase: 32 Terrain: TerrainType@Clear: