made WaterPaletteRotation more configurable
Base is now configurable per terrain ExcludePalettes is now exposed to yaml
This commit is contained in:
@@ -80,6 +80,7 @@ namespace OpenRA.FileFormats
|
||||
public string Palette;
|
||||
public int TileSize = 24;
|
||||
public string[] Extensions;
|
||||
public int WaterPaletteRotationBase = 0x60;
|
||||
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
||||
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
||||
|
||||
|
||||
@@ -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<string,Palette> 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ World:
|
||||
ScreenShaker:
|
||||
NukePaletteEffect:
|
||||
WaterPaletteRotation:
|
||||
Base: 32
|
||||
BuildingInfluence:
|
||||
BridgeLayer:
|
||||
Bridges: bridge1, bridge2, bridge3, bridge4
|
||||
|
||||
@@ -3,6 +3,7 @@ General:
|
||||
Id: DESERT
|
||||
Extensions: .des, .shp, .tem
|
||||
Palette: desert.pal
|
||||
WaterPaletteRotationBase: 32
|
||||
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
|
||||
@@ -3,6 +3,7 @@ General:
|
||||
Id: SNOW
|
||||
Extensions: .sno, .shp, .tem
|
||||
Palette: snow.pal
|
||||
WaterPaletteRotationBase: 32
|
||||
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
|
||||
@@ -3,6 +3,7 @@ General:
|
||||
Id: TEMPERAT
|
||||
Extensions: .tem, .shp
|
||||
Palette: temperat.pal
|
||||
WaterPaletteRotationBase: 32
|
||||
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
|
||||
@@ -3,6 +3,7 @@ General:
|
||||
Id: WINTER
|
||||
Extensions: .win, .shp, .tem
|
||||
Palette: winter.pal
|
||||
WaterPaletteRotationBase: 32
|
||||
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
|
||||
Reference in New Issue
Block a user