diff --git a/OpenRA.Mods.Cnc/CncWaterPaletteRotation.cs b/OpenRA.Mods.Cnc/CncWaterPaletteRotation.cs new file mode 100644 index 0000000000..27df3de5aa --- /dev/null +++ b/OpenRA.Mods.Cnc/CncWaterPaletteRotation.cs @@ -0,0 +1,40 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using System.Drawing; +using OpenRA.Traits; +using System.Collections.Generic; +using OpenRA.FileFormats; + +namespace OpenRA.Mods.Cnc +{ + class CncWaterPaletteRotationInfo : TraitInfo {} + + class CncWaterPaletteRotation : ITick, IPaletteModifier + { + + float t = 0; + public void Tick(Actor self) + { + t += .25f; + } + + public void AdjustPalette(Dictionary palettes) + { + // Only modify the terrain palette + var pal = palettes["terrain"]; + + var copy = (uint[])pal.Values.Clone(); + var rotate = (int)t % 7; + for (int i = 0; i < 7; i++) + pal.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]); + } + } +} diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 7056fa91db..decbcf69b4 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -67,6 +67,7 @@ + diff --git a/OpenRA.Mods.RA/WaterPaletteRotation.cs b/OpenRA.Mods.RA/WaterPaletteRotation.cs index 40126b6def..7ac3796ed7 100644 --- a/OpenRA.Mods.RA/WaterPaletteRotation.cs +++ b/OpenRA.Mods.RA/WaterPaletteRotation.cs @@ -15,20 +15,9 @@ using OpenRA.FileFormats; namespace OpenRA.Mods.RA { - class WaterPaletteRotationInfo : ITraitInfo - { - public readonly bool CncMode = false; - public object Create(ActorInitializer init) { return new WaterPaletteRotation(CncMode); } - } - + class WaterPaletteRotationInfo : TraitInfo {} class WaterPaletteRotation : ITick, IPaletteModifier { - bool cncmode = false; - public WaterPaletteRotation(bool cncmode) - { - this.cncmode = cncmode; - } - float t = 0; public void Tick(Actor self) { @@ -46,12 +35,7 @@ namespace OpenRA.Mods.RA var copy = (uint[])pal.Value.Values.Clone(); var rotate = (int)t % 7; for (int i = 0; i < 7; i++) - { - if (cncmode) - pal.Value.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]); - else - pal.Value.SetColor(0x60 + (rotate + i) % 7, copy[0x60 + i]); - } + pal.Value.SetColor(0x60 + (rotate + i) % 7, copy[0x60 + i]); } } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 6a19c57836..741081285f 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -257,7 +257,7 @@ Priority: 1 RenderBuildingWall: HasMakeAnimation: false - Palette: terrain + Palette: staticterrain GivesExperience: EditorAppearance: RelativeToTopLeft: yes @@ -267,7 +267,7 @@ Tooltip: Name: Tree RenderBuilding: - Palette: terrain + Palette: staticterrain Building: Footprint: __ x_ Dimensions: 2,2 @@ -281,7 +281,7 @@ Tooltip: Name: Rock RenderBuilding: - Palette: terrain + Palette: staticterrain Building: Footprint: __ x_ Dimensions: 2,2 diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index f9b24ec590..34869afa68 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -49,14 +49,15 @@ World: ObserverWidget: OBSERVER_ROOT ScreenShaker: NukePaletteEffect: - WaterPaletteRotation: - CncMode: true + CncWaterPaletteRotation: BuildingInfluence: UnitInfluence: BridgeLayer: Bridges: bridge1, bridge2, bridge3, bridge4 - PaletteFromCurrentTileset: + PaletteFromCurrentTileset@terrain: Name: terrain + PaletteFromCurrentTileset@static: + Name: staticterrain PaletteFromFile@chrome: Name: chrome Filename: temperat.pal @@ -97,7 +98,7 @@ World: ResourceLayer: ResourceType@green-tib: ResourceType: 1 - Palette: terrain + Palette: staticterrain TerrainType: Tiberium SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12 ValuePerUnit: 30 @@ -107,7 +108,7 @@ World: AllowUnderActors: false ResourceType@blue-tib: ResourceType: 2 - Palette: terrain + Palette: staticterrain TerrainType: BlueTiberium SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12 ValuePerUnit: 60 diff --git a/mods/cnc/rules/tech.yaml b/mods/cnc/rules/tech.yaml index 5768bb5998..f7c0f4a000 100644 --- a/mods/cnc/rules/tech.yaml +++ b/mods/cnc/rules/tech.yaml @@ -2,6 +2,7 @@ V19: Inherits: ^CivBuilding RenderBuilding: + Palette: staticterrain CashTrickler: Building: Footprint: x @@ -19,6 +20,7 @@ V19.Husk: -DeadBuildingState: -Health: RenderBuilding: + Palette: staticterrain WithFire: Building: Footprint: x diff --git a/mods/cnc/rules/trees.yaml b/mods/cnc/rules/trees.yaml index 965d7ffc01..90420b01d3 100644 --- a/mods/cnc/rules/trees.yaml +++ b/mods/cnc/rules/trees.yaml @@ -1,7 +1,7 @@ SPLIT2: Inherits: ^Tree RenderBuilding: - Palette: terrain + Palette: staticterrain SeedsResource: ResourceType:Tiberium Tooltip: @@ -13,7 +13,7 @@ SPLIT2: SPLIT3: Inherits: ^Tree RenderBuilding: - Palette: terrain + Palette: staticterrain SeedsResource: ResourceType:Tiberium Tooltip: