fix smudgelayer deepening; make biblayer work the same way (not optimal, but better)
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Drawing;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
@@ -27,8 +28,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
World world;
|
World world;
|
||||||
BibLayerInfo info;
|
BibLayerInfo info;
|
||||||
|
Dictionary<int2, TileReference<byte, byte>> tiles;
|
||||||
TileReference<byte,byte>[,] tiles;
|
|
||||||
Sprite[][] bibSprites;
|
Sprite[][] bibSprites;
|
||||||
|
|
||||||
public BibLayer(Actor self, BibLayerInfo info)
|
public BibLayer(Actor self, BibLayerInfo info)
|
||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Traits
|
|||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
{
|
{
|
||||||
world = w;
|
world = w;
|
||||||
tiles = new TileReference<byte,byte>[w.Map.MapSize.X,w.Map.MapSize.Y];
|
tiles = new Dictionary<int2, TileReference<byte, byte>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoBib(Actor b, bool isAdd)
|
public void DoBib(Actor b, bool isAdd)
|
||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Traits
|
|||||||
byte type = (byte)((isAdd) ? bib+1 : 0);
|
byte type = (byte)((isAdd) ? bib+1 : 0);
|
||||||
byte index = (byte)i;
|
byte index = (byte)i;
|
||||||
|
|
||||||
tiles[p.X,p.Y] = new TileReference<byte,byte>(type,index);
|
tiles[p] = new TileReference<byte,byte>(type,index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,20 +76,15 @@ namespace OpenRA.Traits
|
|||||||
var cliprect = Game.viewport.ShroudBounds().HasValue
|
var cliprect = Game.viewport.ShroudBounds().HasValue
|
||||||
? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
|
? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
|
||||||
|
|
||||||
var minx = cliprect.Left;
|
foreach (var kv in tiles)
|
||||||
var maxx = cliprect.Right;
|
|
||||||
|
|
||||||
var miny = cliprect.Top;
|
|
||||||
var maxy = cliprect.Bottom;
|
|
||||||
|
|
||||||
for (int x = minx; x < maxx; x++)
|
|
||||||
for (int y = miny; y < maxy; y++)
|
|
||||||
{
|
{
|
||||||
var t = new int2(x, y);
|
if (!cliprect.Contains(kv.Key.X, kv.Key.Y))
|
||||||
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
|
continue;
|
||||||
|
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key))
|
||||||
|
continue;
|
||||||
|
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[tiles[x, y].type - 1][tiles[x, y].image],
|
Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[kv.Value.type - 1][kv.Value.image],
|
||||||
Game.CellSize * t, "terrain");
|
Game.CellSize * kv.Key, "terrain");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ namespace OpenRA.Traits
|
|||||||
// Existing smudge; make it deeper
|
// Existing smudge; make it deeper
|
||||||
int depth = Info.Depths[tile.type-1];
|
int depth = Info.Depths[tile.type-1];
|
||||||
if (tile.image < depth - 1)
|
if (tile.image < depth - 1)
|
||||||
|
{
|
||||||
tile.image++;
|
tile.image++;
|
||||||
|
tiles[loc] = tile; // struct semantics.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Render()
|
public void Render()
|
||||||
@@ -81,7 +84,7 @@ namespace OpenRA.Traits
|
|||||||
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key))
|
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite(smudgeSprites[tiles[kv.Key].type- 1][tiles[kv.Key].image],
|
Game.Renderer.SpriteRenderer.DrawSprite(smudgeSprites[kv.Value.type- 1][kv.Value.image],
|
||||||
Game.CellSize * kv.Key, "terrain");
|
Game.CellSize * kv.Key, "terrain");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user