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