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 string Palette;
|
||||||
public int TileSize = 24;
|
public int TileSize = 24;
|
||||||
public string[] Extensions;
|
public string[] Extensions;
|
||||||
|
public int WaterPaletteRotationBase = 0x60;
|
||||||
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
||||||
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
||||||
|
|
||||||
|
|||||||
@@ -17,38 +17,43 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class WaterPaletteRotationInfo : ITraitInfo
|
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
|
class WaterPaletteRotation : ITick, IPaletteModifier
|
||||||
{
|
{
|
||||||
float t = 0;
|
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; }
|
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 */
|
static uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */
|
||||||
|
|
||||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||||
{
|
{
|
||||||
foreach (var pal in palettes)
|
foreach (var pal in palettes)
|
||||||
{
|
{
|
||||||
if (excludePalettes.Contains(pal.Key))
|
if (info.ExcludePalettes.Contains(pal.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var colors = pal.Value.Values;
|
var colors = pal.Value.Values;
|
||||||
var rotate = (int)t % 7;
|
var rotate = (int)t % 7;
|
||||||
|
|
||||||
for (var i = 0; i < 7; i++)
|
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++)
|
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:
|
ScreenShaker:
|
||||||
NukePaletteEffect:
|
NukePaletteEffect:
|
||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
Base: 32
|
|
||||||
BuildingInfluence:
|
BuildingInfluence:
|
||||||
BridgeLayer:
|
BridgeLayer:
|
||||||
Bridges: bridge1, bridge2, bridge3, bridge4
|
Bridges: bridge1, bridge2, bridge3, bridge4
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ General:
|
|||||||
Name: Desert
|
Name: Desert
|
||||||
Id: DESERT
|
Id: DESERT
|
||||||
Extensions: .des, .shp, .tem
|
Extensions: .des, .shp, .tem
|
||||||
Palette: desert.pal
|
Palette: desert.pal
|
||||||
|
WaterPaletteRotationBase: 32
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
TerrainType@Clear:
|
TerrainType@Clear:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ General:
|
|||||||
Id: SNOW
|
Id: SNOW
|
||||||
Extensions: .sno, .shp, .tem
|
Extensions: .sno, .shp, .tem
|
||||||
Palette: snow.pal
|
Palette: snow.pal
|
||||||
|
WaterPaletteRotationBase: 32
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
TerrainType@Clear:
|
TerrainType@Clear:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ General:
|
|||||||
Id: TEMPERAT
|
Id: TEMPERAT
|
||||||
Extensions: .tem, .shp
|
Extensions: .tem, .shp
|
||||||
Palette: temperat.pal
|
Palette: temperat.pal
|
||||||
|
WaterPaletteRotationBase: 32
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
TerrainType@Clear:
|
TerrainType@Clear:
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ General:
|
|||||||
Name: Winter
|
Name: Winter
|
||||||
Id: WINTER
|
Id: WINTER
|
||||||
Extensions: .win, .shp, .tem
|
Extensions: .win, .shp, .tem
|
||||||
Palette: winter.pal
|
Palette: winter.pal
|
||||||
|
WaterPaletteRotationBase: 32
|
||||||
|
|
||||||
Terrain:
|
Terrain:
|
||||||
TerrainType@Clear:
|
TerrainType@Clear:
|
||||||
|
|||||||
Reference in New Issue
Block a user