Merge pull request #9103 from reaperrr/water-rot
Refactored WaterPaletteRotation into RotationPaletteEffect
This commit is contained in:
@@ -171,7 +171,6 @@ namespace OpenRA
|
|||||||
public readonly int SheetSize = 512;
|
public readonly int SheetSize = 512;
|
||||||
public readonly string Palette;
|
public readonly string Palette;
|
||||||
public readonly string PlayerPalette;
|
public readonly string PlayerPalette;
|
||||||
public readonly int WaterPaletteRotationBase = 0x60;
|
|
||||||
public readonly Color[] HeightDebugColors = new[] { Color.Red };
|
public readonly Color[] HeightDebugColors = new[] { Color.Red };
|
||||||
public readonly string[] EditorTemplateOrder;
|
public readonly string[] EditorTemplateOrder;
|
||||||
public readonly bool IgnoreTileSpriteOffsets;
|
public readonly bool IgnoreTileSpriteOffsets;
|
||||||
|
|||||||
@@ -366,7 +366,7 @@
|
|||||||
<Compile Include="Traits\PaletteEffects\GlobalLightingPaletteEffect.cs" />
|
<Compile Include="Traits\PaletteEffects\GlobalLightingPaletteEffect.cs" />
|
||||||
<Compile Include="Traits\PaletteEffects\FlashPaletteEffect.cs" />
|
<Compile Include="Traits\PaletteEffects\FlashPaletteEffect.cs" />
|
||||||
<Compile Include="Traits\PaletteEffects\MenuPaletteEffect.cs" />
|
<Compile Include="Traits\PaletteEffects\MenuPaletteEffect.cs" />
|
||||||
<Compile Include="Traits\PaletteEffects\WaterPaletteRotation.cs" />
|
<Compile Include="Traits\PaletteEffects\RotationPaletteEffect.cs" />
|
||||||
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
|
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
|
||||||
<Compile Include="Traits\Player\AllyRepair.cs" />
|
<Compile Include="Traits\Player\AllyRepair.cs" />
|
||||||
<Compile Include="Traits\Player\BaseAttackNotifier.cs" />
|
<Compile Include="Traits\Player\BaseAttackNotifier.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 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 COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Palette effect used for sprinkle \"animations\".")]
|
||||||
|
class RotationPaletteEffectInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
[Desc("Defines to which palettes this effect should be applied to.",
|
||||||
|
"If none specified, it applies to all palettes not explicitly excluded.")]
|
||||||
|
public readonly HashSet<string> Palettes = new HashSet<string>();
|
||||||
|
|
||||||
|
[Desc("Defines for which tileset IDs this effect should be loaded.",
|
||||||
|
"If none specified, it applies to all tileset IDs not explicitly excluded.")]
|
||||||
|
public readonly HashSet<string> Tilesets = new HashSet<string>();
|
||||||
|
|
||||||
|
[Desc("Defines which palettes should be excluded from this effect.")]
|
||||||
|
public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
|
||||||
|
|
||||||
|
[Desc("Don't apply the effect for these tileset IDs.")]
|
||||||
|
public readonly HashSet<string> ExcludeTilesets = new HashSet<string>();
|
||||||
|
|
||||||
|
[Desc("Palette index of first RotationRange color.")]
|
||||||
|
public readonly int RotationBase = 0x60;
|
||||||
|
|
||||||
|
[Desc("Range of colors to rotate.")]
|
||||||
|
public readonly int RotationRange = 7;
|
||||||
|
|
||||||
|
[Desc("Step towards next color index per tick.")]
|
||||||
|
public readonly float RotationStep = .25f;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new RotationPaletteEffect(init.World, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class RotationPaletteEffect : ITick, IPaletteModifier
|
||||||
|
{
|
||||||
|
readonly RotationPaletteEffectInfo info;
|
||||||
|
readonly uint[] rotationBuffer;
|
||||||
|
readonly bool validTileset;
|
||||||
|
readonly string tilesetId;
|
||||||
|
float t = 0;
|
||||||
|
|
||||||
|
public RotationPaletteEffect(World world, RotationPaletteEffectInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
rotationBuffer = new uint[info.RotationRange];
|
||||||
|
tilesetId = world.TileSet.Id;
|
||||||
|
|
||||||
|
validTileset = IsValidTileset();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValidTileset()
|
||||||
|
{
|
||||||
|
if (info.Tilesets.Count == 0 && info.ExcludeTilesets.Count == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return info.Tilesets.Contains(tilesetId) && !info.ExcludeTilesets.Contains(tilesetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick(Actor self)
|
||||||
|
{
|
||||||
|
if (!validTileset)
|
||||||
|
return;
|
||||||
|
|
||||||
|
t += info.RotationStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||||
|
{
|
||||||
|
if (!validTileset)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var rotate = (int)t % info.RotationRange;
|
||||||
|
if (rotate == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var kvp in palettes)
|
||||||
|
{
|
||||||
|
if ((info.Palettes.Count > 0 && !info.Palettes.Any(kvp.Key.StartsWith))
|
||||||
|
|| (info.ExcludePalettes.Count > 0 && info.ExcludePalettes.Any(kvp.Key.StartsWith)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var palette = kvp.Value;
|
||||||
|
|
||||||
|
for (var i = 0; i < info.RotationRange; i++)
|
||||||
|
rotationBuffer[(rotate + i) % info.RotationRange] = palette[info.RotationBase + i];
|
||||||
|
|
||||||
|
for (var i = 0; i < info.RotationRange; i++)
|
||||||
|
palette[info.RotationBase + i] = rotationBuffer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2015 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 COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
|
||||||
{
|
|
||||||
[Desc("Palette effect used for sprinkle \"animations\" on terrain tiles.")]
|
|
||||||
class WaterPaletteRotationInfo : ITraitInfo
|
|
||||||
{
|
|
||||||
public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
|
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.World, this); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class WaterPaletteRotation : ITick, IPaletteModifier
|
|
||||||
{
|
|
||||||
readonly WaterPaletteRotationInfo info;
|
|
||||||
readonly World world;
|
|
||||||
float t = 0;
|
|
||||||
|
|
||||||
public WaterPaletteRotation(World world, WaterPaletteRotationInfo info)
|
|
||||||
{
|
|
||||||
this.world = world;
|
|
||||||
this.info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Tick(Actor self) { t += .25f; }
|
|
||||||
|
|
||||||
uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */
|
|
||||||
|
|
||||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
|
||||||
{
|
|
||||||
var rotate = (int)t % 7;
|
|
||||||
if (rotate == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var kvp in palettes)
|
|
||||||
{
|
|
||||||
if (info.ExcludePalettes.Contains(kvp.Key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var palette = kvp.Value;
|
|
||||||
|
|
||||||
for (var i = 0; i < 7; i++)
|
|
||||||
temp[(rotate + i) % 7] = palette[world.TileSet.WaterPaletteRotationBase + i];
|
|
||||||
|
|
||||||
for (var i = 0; i < 7; i++)
|
|
||||||
palette[world.TileSet.WaterPaletteRotationBase + i] = temp[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2051,6 +2051,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WaterPaletteRotation renamed to RotationPaletteEffect
|
||||||
|
if (engineVersion < 20150903)
|
||||||
|
{
|
||||||
|
if (depth == 1 && node.Key == "WaterPaletteRotation")
|
||||||
|
node.Key = "RotationPaletteEffect";
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
MenuEffect: Desaturated
|
MenuEffect: Desaturated
|
||||||
CloakPaletteEffect:
|
CloakPaletteEffect:
|
||||||
FlashPaletteEffect:
|
FlashPaletteEffect:
|
||||||
WaterPaletteRotation:
|
RotationPaletteEffect@water:
|
||||||
ExcludePalettes: effect
|
ExcludePalettes: effect, chrome
|
||||||
|
RotationBase: 32
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ General:
|
|||||||
Name: Desert
|
Name: Desert
|
||||||
Id: DESERT
|
Id: DESERT
|
||||||
Palette: desert.pal
|
Palette: desert.pal
|
||||||
WaterPaletteRotationBase: 32
|
|
||||||
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ General:
|
|||||||
Name: Jungle
|
Name: Jungle
|
||||||
Id: JUNGLE
|
Id: JUNGLE
|
||||||
Palette: jungle.pal
|
Palette: jungle.pal
|
||||||
WaterPaletteRotationBase: 32
|
|
||||||
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ General:
|
|||||||
Name: Snow
|
Name: Snow
|
||||||
Id: SNOW
|
Id: SNOW
|
||||||
Palette: snow.pal
|
Palette: snow.pal
|
||||||
WaterPaletteRotationBase: 32
|
|
||||||
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ General:
|
|||||||
Name: Temperate
|
Name: Temperate
|
||||||
Id: TEMPERAT
|
Id: TEMPERAT
|
||||||
Palette: temperat.pal
|
Palette: temperat.pal
|
||||||
WaterPaletteRotationBase: 32
|
|
||||||
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ General:
|
|||||||
Name: Winter
|
Name: Winter
|
||||||
Id: WINTER
|
Id: WINTER
|
||||||
Palette: winter.pal
|
Palette: winter.pal
|
||||||
WaterPaletteRotationBase: 32
|
|
||||||
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
^Palettes:
|
^Palettes:
|
||||||
PlayerPaletteFromCurrentTileset:
|
PaletteFromFile@player:
|
||||||
Name: player
|
Name: player
|
||||||
ShadowIndex: 3,4
|
Filename: temperat.pal
|
||||||
|
ShadowIndex: 4
|
||||||
PaletteFromCurrentTileset:
|
PaletteFromCurrentTileset:
|
||||||
Name: terrain
|
Name: terrain
|
||||||
ShadowIndex: 3,4
|
ShadowIndex: 3,4
|
||||||
@@ -66,8 +67,15 @@
|
|||||||
RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
|
RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
|
||||||
PlayerHighlightPalette:
|
PlayerHighlightPalette:
|
||||||
MenuPaletteEffect:
|
MenuPaletteEffect:
|
||||||
WaterPaletteRotation:
|
RotationPaletteEffect@defaultwater:
|
||||||
ExcludePalettes: player, effect
|
Palettes: terrain
|
||||||
|
ExcludeTilesets: DESERT
|
||||||
|
RotationPaletteEffect@actorswater:
|
||||||
|
Palettes: player, effect
|
||||||
|
RotationPaletteEffect@desertwater:
|
||||||
|
Palettes: terrain
|
||||||
|
Tilesets: DESERT
|
||||||
|
RotationBase: 32
|
||||||
LightPaletteRotator:
|
LightPaletteRotator:
|
||||||
ExcludePalettes: terrain, effect
|
ExcludePalettes: terrain, effect
|
||||||
ChronoshiftPaletteEffect:
|
ChronoshiftPaletteEffect:
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ General:
|
|||||||
Id: DESERT
|
Id: DESERT
|
||||||
Palette: desert.pal
|
Palette: desert.pal
|
||||||
PlayerPalette: temperat.pal
|
PlayerPalette: temperat.pal
|
||||||
WaterPaletteRotationBase: 32
|
|
||||||
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Water Cliffs, Beach, River, Bridge
|
EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Water Cliffs, Beach, River, Bridge
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
|
|||||||
Reference in New Issue
Block a user