fix smudgelayer deepening; make biblayer work the same way (not optimal, but better)

This commit is contained in:
Chris Forbes
2010-09-06 18:11:58 +12:00
parent 7f7f4e81a5
commit c5f0dad84e
2 changed files with 25 additions and 27 deletions

View File

@@ -13,6 +13,7 @@ using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using System.Collections.Generic;
namespace OpenRA.Traits
{
@@ -27,8 +28,7 @@ namespace OpenRA.Traits
{
World world;
BibLayerInfo info;
TileReference<byte,byte>[,] tiles;
Dictionary<int2, TileReference<byte, byte>> tiles;
Sprite[][] bibSprites;
public BibLayer(Actor self, BibLayerInfo info)
@@ -45,7 +45,7 @@ namespace OpenRA.Traits
public void WorldLoaded(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)
@@ -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);
}
}
@@ -76,20 +76,15 @@ 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++)
foreach (var kv in tiles)
{
var t = new int2(x, y);
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
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[tiles[x, y].type - 1][tiles[x, y].image],
Game.CellSize * t, "terrain");
Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[kv.Value.type - 1][kv.Value.image],
Game.CellSize * kv.Key, "terrain");
}
}
}

View File

@@ -66,7 +66,10 @@ namespace OpenRA.Traits
// Existing smudge; make it deeper
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");
}
}