diff --git a/OpenRA.Game/Graphics/Theater.cs b/OpenRA.Game/Graphics/Theater.cs index 116c1ba6d0..8adbd2ff24 100644 --- a/OpenRA.Game/Graphics/Theater.cs +++ b/OpenRA.Game/Graphics/Theater.cs @@ -43,16 +43,18 @@ namespace OpenRA.Graphics { this.tileset = tileset; var allocated = false; + var type = tileset.EnableDepth ? SheetType.DualIndexed : SheetType.Indexed; + Func allocate = () => { if (allocated) throw new SheetOverflowException("Terrain sheet overflow. Try increasing the tileset SheetSize parameter."); allocated = true; - return new Sheet(SheetType.Indexed, new Size(tileset.SheetSize, tileset.SheetSize)); + return new Sheet(type, new Size(tileset.SheetSize, tileset.SheetSize)); }; - sheetBuilder = new SheetBuilder(SheetType.Indexed, allocate); + sheetBuilder = new SheetBuilder(type, allocate); random = new MersenneTwister(); var frameCache = new FrameCache(Game.ModData.SpriteLoaders); @@ -63,8 +65,19 @@ namespace OpenRA.Graphics foreach (var i in t.Value.Images) { var allFrames = frameCache[i]; - var frames = t.Value.Frames != null ? t.Value.Frames.Select(f => allFrames[f]).ToArray() : allFrames; - variants.Add(frames.Select(f => sheetBuilder.Add(f)).ToArray()); + var frameCount = tileset.EnableDepth ? allFrames.Length / 2 : allFrames.Length; + var indices = t.Value.Frames != null ? t.Value.Frames : Enumerable.Range(0, frameCount); + variants.Add(indices.Select(j => + { + var f = allFrames[j]; + var s = sheetBuilder.Allocate(f.Size, f.Offset); + Util.FastCopyIntoChannel(s, 0, f.Data); + + if (tileset.EnableDepth) + Util.FastCopyIntoChannel(s, 1, allFrames[j + frameCount].Data); + + return s; + }).ToArray()); } var allSprites = variants.SelectMany(s => s); diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index 5ae0d38808..c886fd1ed4 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -174,6 +174,7 @@ namespace OpenRA public readonly Color[] HeightDebugColors = new[] { Color.Red }; public readonly string[] EditorTemplateOrder; public readonly bool IgnoreTileSpriteOffsets; + public readonly bool EnableDepth = false; [FieldLoader.Ignore] public readonly IReadOnlyDictionary Templates; diff --git a/mods/ts/tilesets/snow.yaml b/mods/ts/tilesets/snow.yaml index e2ae5926fe..c2bfda99b9 100644 --- a/mods/ts/tilesets/snow.yaml +++ b/mods/ts/tilesets/snow.yaml @@ -5,6 +5,7 @@ General: HeightDebugColors: 128,0,0,0, 128,0,0,68, 128,0,0,136, 128,0,0,204, 128,0,0,255, 128,68,0,204, 128,136,0,136, 128,204,0,68, 128,255,17,0, 128,255,85,0, 128,255,153,0, 128,255,221,0, 128,221,255,0, 128,153,255,0, 128,85,255,0, 128,17,255,0 EditorTemplateOrder: Bendy Dirt Roads, Blank, Bridges, Civilian Buildings, Clear, Clear/Rough LAT, Cliff Pieces, Cliff Set, Cliff/Water pieces, Dead Oil Tanker, Destroyable Cliffs, Dirt Road Junctions, Dirt Road Slopes, DirtTrackTunnel Floor, DirtTunnel Floor, Grey/Clear LAT, House, Ice Flow, Ice Ramps, Ice shore, Misc Buildings, Monorail Slopes, Paved Road Ends, Paved Road Slopes, Paved Roads, Pavement, Pavement (Use for LAT), Pavement/Clear LAT, Ramp edge fixup, Rough ground, Rough lat, Ruins, Shore Pieces, Slope Set Pieces, Straight Dirt Roads, TrackTunnel Floor, TrainBridges, Tunnel Side, Tunnels, Water, Water slopes, Waterfalls, Waterfalls-B, Waterfalls-C, Waterfalls-D SheetSize: 2048 + EnableDepth: true Terrain: TerrainType@Clear: diff --git a/mods/ts/tilesets/temperate.yaml b/mods/ts/tilesets/temperate.yaml index 260d08f338..d4655b9761 100644 --- a/mods/ts/tilesets/temperate.yaml +++ b/mods/ts/tilesets/temperate.yaml @@ -5,6 +5,7 @@ General: HeightDebugColors: 128,0,0,0, 128,0,0,68, 128,0,0,136, 128,0,0,204, 128,0,0,255, 128,68,0,204, 128,136,0,136, 128,204,0,68, 128,255,17,0, 128,255,85,0, 128,255,153,0, 128,255,221,0, 128,221,255,0, 128,153,255,0, 128,85,255,0, 128,17,255,0 EditorTemplateOrder: Misc Buildings, Clear, Cliff Pieces, Ice Flow, House, Blank, Ice Ramps, Cliff Set, Civilian Buildings, Shore Pieces, Rough LAT tile, Clear/Rough LAT, Cliff/Water pieces, Bendy Dirt Roads, Dirt Road Junctions, Straight Dirt Roads, Bridges, Paved Roads, Water, Dirt Road Slopes, Slope Set Pieces, Dead Oil Tanker, Ruins, Waterfalls, Ground 01, Ground 02, Sand, Sand/Clear LAT, Rough ground, Paved Road Ends, TrainBridges, Pavement, Pavement/Clear LAT, Paved road bits, Green, Green/Clear LAT, Ramp edge fixup, Water slopes, Pavement (Use for LAT), Paved Road Slopes, Monorail Slopes, Waterfalls-B, Waterfalls-C, Waterfalls-D, Tunnel Floor, Tunnel Side, TrackTunnel Floor, Destroyable Cliffs, Water Caves, Scrin Wreckage, DirtTrackTunnel Floor, DirtTunnel Floor SheetSize: 2048 + EnableDepth: true Terrain: TerrainType@Clear: