Changed some identifier names from BlockXX to XX, since they're no longer part of an overloaded chunk interface.

This commit is contained in:
Justin Aquadro 2011-05-13 03:21:53 +00:00
parent b7eefbea0e
commit d56fcc288f
9 changed files with 96 additions and 96 deletions

View file

@ -48,7 +48,7 @@ namespace FlatMap
// Reset and rebuild the lighting for the entire chunk at once // Reset and rebuild the lighting for the entire chunk at once
chunk.Blocks.RebuildBlockLight(); chunk.Blocks.RebuildBlockLight();
chunk.Blocks.RebuildBlockSkyLight(); chunk.Blocks.RebuildSkyLight();
Console.WriteLine("Built Chunk {0},{1}", chunk.X, chunk.Z); Console.WriteLine("Built Chunk {0},{1}", chunk.X, chunk.Z);
@ -68,7 +68,7 @@ namespace FlatMap
for (int y = 0; y < 2; y++) { for (int y = 0; y < 2; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
chunk.Blocks.SetBlockID(x, y, z, (int)BlockType.BEDROCK); chunk.Blocks.SetID(x, y, z, (int)BlockType.BEDROCK);
} }
} }
} }
@ -77,7 +77,7 @@ namespace FlatMap
for (int y = 2; y < height - 5; y++) { for (int y = 2; y < height - 5; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
chunk.Blocks.SetBlockID(x, y, z, (int)BlockType.STONE); chunk.Blocks.SetID(x, y, z, (int)BlockType.STONE);
} }
} }
} }
@ -86,7 +86,7 @@ namespace FlatMap
for (int y = height - 5; y < height - 1; y++) { for (int y = height - 5; y < height - 1; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
chunk.Blocks.SetBlockID(x, y, z, (int)BlockType.DIRT); chunk.Blocks.SetID(x, y, z, (int)BlockType.DIRT);
} }
} }
} }
@ -95,7 +95,7 @@ namespace FlatMap
for (int y = height - 1; y < height; y++) { for (int y = height - 1; y < height; y++) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
chunk.Blocks.SetBlockID(x, y, z, (int)BlockType.GRASS); chunk.Blocks.SetID(x, y, z, (int)BlockType.GRASS);
} }
} }
} }

View file

@ -31,7 +31,7 @@ namespace Relight
chunk.Blocks.RebuildHeightMap(); chunk.Blocks.RebuildHeightMap();
chunk.Blocks.ResetBlockLight(); chunk.Blocks.ResetBlockLight();
chunk.Blocks.ResetBlockSkyLight(); chunk.Blocks.ResetSkyLight();
cm.Save(); cm.Save();
Console.WriteLine("Reset Chunk {0},{1}", chunk.X, chunk.Z); Console.WriteLine("Reset Chunk {0},{1}", chunk.X, chunk.Z);
@ -42,7 +42,7 @@ namespace Relight
if (chunk.X < -20 || chunk.X > 0 || chunk.Z < -20 || chunk.Z > 0) continue; if (chunk.X < -20 || chunk.X > 0 || chunk.Z < -20 || chunk.Z > 0) continue;
chunk.Blocks.RebuildBlockLight(); chunk.Blocks.RebuildBlockLight();
chunk.Blocks.RebuildBlockSkyLight(); chunk.Blocks.RebuildSkyLight();
// Save the chunk to disk so it doesn't hang around in RAM // Save the chunk to disk so it doesn't hang around in RAM
cm.Save(); cm.Save();

View file

@ -122,8 +122,8 @@ namespace Substrate
public void SetBlock (int x, int y, int z, Block block) public void SetBlock (int x, int y, int z, Block block)
{ {
SetBlockID(x, y, z, block.ID); SetID(x, y, z, block.ID);
SetBlockData(x, y, z, block.Data); SetData(x, y, z, block.Data);
SetTileEntity(x, y, z, block.GetTileEntity().Copy()); SetTileEntity(x, y, z, block.GetTileEntity().Copy());
} }
@ -157,20 +157,20 @@ namespace Substrate
public void SetBlock (int x, int y, int z, IBlock block) public void SetBlock (int x, int y, int z, IBlock block)
{ {
SetBlockID(x, y, z, block.ID); SetID(x, y, z, block.ID);
} }
public BlockInfo GetBlockInfo (int x, int y, int z) public BlockInfo GetInfo (int x, int y, int z)
{ {
return BlockInfo.BlockTable[_blocks[x, y, z]]; return BlockInfo.BlockTable[_blocks[x, y, z]];
} }
public int GetBlockID (int x, int y, int z) public int GetID (int x, int y, int z)
{ {
return _blocks[x, y, z]; return _blocks[x, y, z];
} }
public void SetBlockID (int x, int y, int z, int id) public void SetID (int x, int y, int z, int id)
{ {
int oldid = _blocks[x, y, z]; int oldid = _blocks[x, y, z];
if (oldid == id) { if (oldid == id) {
@ -223,14 +223,14 @@ namespace Substrate
} }
if (info1.Opacity != info2.Opacity) { if (info1.Opacity != info2.Opacity) {
UpdateBlockSkyLight(x, y, z); UpdateSkyLight(x, y, z);
} }
} }
_dirty = true; _dirty = true;
} }
public int CountBlockID (int id) public int CountByID (int id)
{ {
int c = 0; int c = 0;
for (int i = 0; i < _blocks.Length; i++) { for (int i = 0; i < _blocks.Length; i++) {
@ -259,16 +259,16 @@ namespace Substrate
public void SetBlock (int x, int y, int z, IDataBlock block) public void SetBlock (int x, int y, int z, IDataBlock block)
{ {
SetBlockID(x, y, z, block.ID); SetID(x, y, z, block.ID);
SetBlockData(x, y, z, block.Data); SetData(x, y, z, block.Data);
} }
public int GetBlockData (int x, int y, int z) public int GetData (int x, int y, int z)
{ {
return _data[x, y, z]; return _data[x, y, z];
} }
public void SetBlockData (int x, int y, int z, int data) public void SetData (int x, int y, int z, int data)
{ {
if (_data[x, y, z] != data) { if (_data[x, y, z] != data) {
_data[x, y, z] = (byte)data; _data[x, y, z] = (byte)data;
@ -282,7 +282,7 @@ namespace Substrate
}*/ }*/
} }
public int CountBlockData (int id, int data) public int CountByData (int id, int data)
{ {
int c = 0; int c = 0;
for (int i = 0; i < _blocks.Length; i++) { for (int i = 0; i < _blocks.Length; i++) {
@ -311,9 +311,9 @@ namespace Substrate
public void SetBlock (int x, int y, int z, ILitBlock block) public void SetBlock (int x, int y, int z, ILitBlock block)
{ {
SetBlockID(x, y, z, block.ID); SetID(x, y, z, block.ID);
SetBlockLight(x, y, z, block.BlockLight); SetBlockLight(x, y, z, block.BlockLight);
SetBlockSkyLight(x, y, z, block.SkyLight); SetSkyLight(x, y, z, block.SkyLight);
} }
public int GetBlockLight (int x, int y, int z) public int GetBlockLight (int x, int y, int z)
@ -321,7 +321,7 @@ namespace Substrate
return _blockLight[x, y, z]; return _blockLight[x, y, z];
} }
public int GetBlockSkyLight (int x, int y, int z) public int GetSkyLight (int x, int y, int z)
{ {
return _skyLight[x, y, z]; return _skyLight[x, y, z];
} }
@ -334,7 +334,7 @@ namespace Substrate
} }
} }
public void SetBlockSkyLight (int x, int y, int z, int light) public void SetSkyLight (int x, int y, int z, int light)
{ {
if (_skyLight[x, y, z] != light) { if (_skyLight[x, y, z] != light) {
_skyLight[x, y, z] = (byte)light; _skyLight[x, y, z] = (byte)light;
@ -358,7 +358,7 @@ namespace Substrate
_dirty = true; _dirty = true;
} }
public void UpdateBlockSkyLight (int x, int y, int z) public void UpdateSkyLight (int x, int y, int z)
{ {
_lightManager.UpdateBlockSkyLight(x, y, z); _lightManager.UpdateBlockSkyLight(x, y, z);
_dirty = true; _dirty = true;
@ -370,7 +370,7 @@ namespace Substrate
_dirty = true; _dirty = true;
} }
public void ResetBlockSkyLight () public void ResetSkyLight ()
{ {
_skyLight.Clear(); _skyLight.Clear();
_dirty = true; _dirty = true;
@ -382,7 +382,7 @@ namespace Substrate
_dirty = true; _dirty = true;
} }
public void RebuildBlockSkyLight () public void RebuildSkyLight ()
{ {
_lightManager.RebuildBlockSkyLight(); _lightManager.RebuildBlockSkyLight();
_dirty = true; _dirty = true;
@ -400,7 +400,7 @@ namespace Substrate
_dirty = true; _dirty = true;
} }
public void StitchBlockSkyLight () public void StitchSkyLight ()
{ {
_lightManager.StitchBlockSkyLight(); _lightManager.StitchBlockSkyLight();
_dirty = true; _dirty = true;
@ -412,7 +412,7 @@ namespace Substrate
_dirty = true; _dirty = true;
} }
public void StitchBlockSkyLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge) public void StitchSkyLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge)
{ {
_lightManager.StitchBlockSkyLight(blockset, edge); _lightManager.StitchBlockSkyLight(blockset, edge);
_dirty = true; _dirty = true;
@ -435,7 +435,7 @@ namespace Substrate
public void SetBlock (int x, int y, int z, IPropertyBlock block) public void SetBlock (int x, int y, int z, IPropertyBlock block)
{ {
SetBlockID(x, y, z, block.ID); SetID(x, y, z, block.ID);
SetTileEntity(x, y, z, block.GetTileEntity().Copy()); SetTileEntity(x, y, z, block.GetTileEntity().Copy());
} }

View file

@ -27,8 +27,8 @@ namespace Substrate
public Block (IAlphaBlockCollection chunk, int lx, int ly, int lz) public Block (IAlphaBlockCollection chunk, int lx, int ly, int lz)
{ {
_id = chunk.GetBlockID(lx, ly, lz); _id = chunk.GetID(lx, ly, lz);
_data = chunk.GetBlockData(lx, ly, lz); _data = chunk.GetData(lx, ly, lz);
_tileEntity = chunk.GetTileEntity(lx, ly, lz).Copy(); _tileEntity = chunk.GetTileEntity(lx, ly, lz).Copy();
} }

View file

@ -43,10 +43,10 @@ namespace Substrate
void SetBlock (int x, int y, int z, IBlock block); void SetBlock (int x, int y, int z, IBlock block);
int GetBlockID (int x, int y, int z); int GetID (int x, int y, int z);
void SetBlockID (int x, int y, int z, int id); void SetID (int x, int y, int z, int id);
BlockInfo GetBlockInfo (int x, int y, int z); BlockInfo GetInfo (int x, int y, int z);
} }
public interface IBoundedBlockCollection : IBlockCollection public interface IBoundedBlockCollection : IBlockCollection
@ -55,7 +55,7 @@ namespace Substrate
int YDim { get; } int YDim { get; }
int ZDim { get; } int ZDim { get; }
int CountBlockID (int id); int CountByID (int id);
} }
public interface IDataBlockCollection : IBlockCollection public interface IDataBlockCollection : IBlockCollection
@ -65,13 +65,13 @@ namespace Substrate
void SetBlock (int x, int y, int z, IDataBlock block); void SetBlock (int x, int y, int z, IDataBlock block);
int GetBlockData (int x, int y, int z); int GetData (int x, int y, int z);
void SetBlockData (int x, int y, int z, int data); void SetData (int x, int y, int z, int data);
} }
public interface IBoundedDataBlockCollection : IDataBlockCollection, IBoundedBlockCollection public interface IBoundedDataBlockCollection : IDataBlockCollection, IBoundedBlockCollection
{ {
int CountBlockData (int id, int data); int CountByData (int id, int data);
} }
public interface ILitBlockCollection : IBlockCollection public interface ILitBlockCollection : IBlockCollection
@ -83,36 +83,36 @@ namespace Substrate
// Local Light // Local Light
int GetBlockLight (int x, int y, int z); int GetBlockLight (int x, int y, int z);
int GetBlockSkyLight (int x, int y, int z); int GetSkyLight (int x, int y, int z);
void SetBlockLight (int x, int y, int z, int light); void SetBlockLight (int x, int y, int z, int light);
void SetBlockSkyLight (int x, int y, int z, int light); void SetSkyLight (int x, int y, int z, int light);
int GetHeight (int x, int z); int GetHeight (int x, int z);
void SetHeight (int x, int z, int height); void SetHeight (int x, int z, int height);
// Update and propagate light at a single block // Update and propagate light at a single block
void UpdateBlockLight (int x, int y, int z); void UpdateBlockLight (int x, int y, int z);
void UpdateBlockSkyLight (int x, int y, int z); void UpdateSkyLight (int x, int y, int z);
} }
public interface IBoundedLitBlockCollection : ILitBlockCollection, IBoundedBlockCollection public interface IBoundedLitBlockCollection : ILitBlockCollection, IBoundedBlockCollection
{ {
// Zero out light in entire collection // Zero out light in entire collection
void ResetBlockLight (); void ResetBlockLight ();
void ResetBlockSkyLight (); void ResetSkyLight ();
// Recalculate light in entire collection // Recalculate light in entire collection
void RebuildBlockLight (); void RebuildBlockLight ();
void RebuildBlockSkyLight (); void RebuildSkyLight ();
void RebuildHeightMap (); void RebuildHeightMap ();
// Reconcile inconsistent lighting between the edges of two containers of same size // Reconcile inconsistent lighting between the edges of two containers of same size
void StitchBlockLight (); void StitchBlockLight ();
void StitchBlockSkyLight (); void StitchSkyLight ();
void StitchBlockLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge); void StitchBlockLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge);
void StitchBlockSkyLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge); void StitchSkyLight (IBoundedLitBlockCollection blockset, BlockCollectionEdge edge);
} }
public interface IPropertyBlockCollection : IBlockCollection public interface IPropertyBlockCollection : IBlockCollection

View file

@ -80,7 +80,7 @@ namespace Substrate
for (int x = 0; x < _blockset.XDim; x++) { for (int x = 0; x < _blockset.XDim; x++) {
for (int z = 0; z < _blockset.ZDim; z++) { for (int z = 0; z < _blockset.ZDim; z++) {
for (int y = 0; y < _blockset.YDim; y++) { for (int y = 0; y < _blockset.YDim; y++) {
BlockInfo info = _blockset.GetBlockInfo(x, y, z); BlockInfo info = _blockset.GetInfo(x, y, z);
if (info.Luminance > 0) { if (info.Luminance > 0) {
SpreadBlockLight(x, y, z); SpreadBlockLight(x, y, z);
} }
@ -107,7 +107,7 @@ namespace Substrate
h = Math.Max(h, heightMap[xi, zi + 1]); h = Math.Max(h, heightMap[xi, zi + 1]);
for (int y = h + 1; y < _blockset.YDim; y++) { for (int y = h + 1; y < _blockset.YDim; y++) {
_blockset.SetBlockSkyLight(x, y, z, BlockInfo.MAX_LUMINANCE); _blockset.SetSkyLight(x, y, z, BlockInfo.MAX_LUMINANCE);
} }
//QueueRelight(new BlockKey(x, h, z)); //QueueRelight(new BlockKey(x, h, z));
@ -121,7 +121,7 @@ namespace Substrate
for (int x = 0; x < _blockset.XDim; x++) { for (int x = 0; x < _blockset.XDim; x++) {
for (int z = 0; z < _blockset.ZDim; z++) { for (int z = 0; z < _blockset.ZDim; z++) {
for (int y = _blockset.YDim - 1; y >= 0; y--) { for (int y = _blockset.YDim - 1; y >= 0; y--) {
BlockInfo info = _blockset.GetBlockInfo(x, y, z); BlockInfo info = _blockset.GetInfo(x, y, z);
if (info.Opacity > BlockInfo.MIN_OPACITY || !info.TransmitsLight) { if (info.Opacity > BlockInfo.MIN_OPACITY || !info.TransmitsLight) {
_blockset.SetHeight(x, z, y); _blockset.SetHeight(x, z, y);
break; break;
@ -284,7 +284,7 @@ namespace Substrate
int z = (k.z + _blockset.ZDim * 2) % _blockset.ZDim; int z = (k.z + _blockset.ZDim * 2) % _blockset.ZDim;
int lightval = cc.GetBlockLight(x, y, z); int lightval = cc.GetBlockLight(x, y, z);
BlockInfo info = cc.GetBlockInfo(x, y, z); BlockInfo info = cc.GetInfo(x, y, z);
int light = Math.Max(info.Luminance, 0); int light = Math.Max(info.Luminance, 0);
light = Math.Max(light, lle - 1); light = Math.Max(light, lle - 1);
@ -327,8 +327,8 @@ namespace Substrate
int y = k.y; int y = k.y;
int z = (k.z + _blockset.ZDim) % _blockset.ZDim; int z = (k.z + _blockset.ZDim) % _blockset.ZDim;
int lightval = cc.GetBlockSkyLight(x, y, z); int lightval = cc.GetSkyLight(x, y, z);
BlockInfo info = cc.GetBlockInfo(x, y, z); BlockInfo info = cc.GetInfo(x, y, z);
int light = BlockInfo.MIN_LUMINANCE; int light = BlockInfo.MIN_LUMINANCE;
@ -356,7 +356,7 @@ namespace Substrate
if (light != lightval) { if (light != lightval) {
//Console.WriteLine("Block SkyLight: ({0},{1},{2}) " + lightval + " -> " + light, k.x, k.y, k.z); //Console.WriteLine("Block SkyLight: ({0},{1},{2}) " + lightval + " -> " + light, k.x, k.y, k.z);
cc.SetBlockSkyLight(x, y, z, light); cc.SetSkyLight(x, y, z, light);
QueueRelight(new BlockKey(k.x - 1, k.y, k.z)); QueueRelight(new BlockKey(k.x - 1, k.y, k.z));
QueueRelight(new BlockKey(k.x + 1, k.y, k.z)); QueueRelight(new BlockKey(k.x + 1, k.y, k.z));
@ -371,7 +371,7 @@ namespace Substrate
private void SpreadBlockLight (int lx, int ly, int lz) private void SpreadBlockLight (int lx, int ly, int lz)
{ {
BlockInfo primary = _blockset.GetBlockInfo(lx, ly, lz); BlockInfo primary = _blockset.GetInfo(lx, ly, lz);
int primaryLight = _blockset.GetBlockLight(lx, ly, lz); int primaryLight = _blockset.GetBlockLight(lx, ly, lz);
int priLum = Math.Max(primary.Luminance - primary.Opacity, 0); int priLum = Math.Max(primary.Luminance - primary.Opacity, 0);
@ -403,7 +403,7 @@ namespace Substrate
int y = rec.y; int y = rec.y;
int z = (rec.z + _blockset.ZDim) % _blockset.ZDim; int z = (rec.z + _blockset.ZDim) % _blockset.ZDim;
BlockInfo info = cc.GetBlockInfo(x, y, z); BlockInfo info = cc.GetInfo(x, y, z);
int light = cc.GetBlockLight(x, y, z); int light = cc.GetBlockLight(x, y, z);
int dimStr = Math.Max(rec.str - info.Opacity, 0); int dimStr = Math.Max(rec.str - info.Opacity, 0);
@ -425,12 +425,12 @@ namespace Substrate
private void SpreadSkyLight (IBoundedLitBlockCollection[,] chunkMap, int[,] heightMap, int lx, int ly, int lz) private void SpreadSkyLight (IBoundedLitBlockCollection[,] chunkMap, int[,] heightMap, int lx, int ly, int lz)
{ {
BlockInfo primary = _blockset.GetBlockInfo(lx, ly, lz); BlockInfo primary = _blockset.GetInfo(lx, ly, lz);
int primaryLight = _blockset.GetBlockSkyLight(lx, ly, lz); int primaryLight = _blockset.GetSkyLight(lx, ly, lz);
int priLum = Math.Max(BlockInfo.MAX_LUMINANCE - primary.Opacity, 0); int priLum = Math.Max(BlockInfo.MAX_LUMINANCE - primary.Opacity, 0);
if (primaryLight < priLum) { if (primaryLight < priLum) {
_blockset.SetBlockSkyLight(lx, ly, lz, priLum); _blockset.SetSkyLight(lx, ly, lz, priLum);
} }
if (primaryLight > BlockInfo.MAX_LUMINANCE - 1 || !primary.TransmitsLight) { if (primaryLight > BlockInfo.MAX_LUMINANCE - 1 || !primary.TransmitsLight) {
@ -480,13 +480,13 @@ namespace Substrate
int y = rec.y; int y = rec.y;
int z = zi % _blockset.ZDim; int z = zi % _blockset.ZDim;
BlockInfo info = cc.GetBlockInfo(x, y, z); BlockInfo info = cc.GetInfo(x, y, z);
int light = cc.GetBlockSkyLight(x, y, z); int light = cc.GetSkyLight(x, y, z);
int dimStr = Math.Max(rec.str - info.Opacity, 0); int dimStr = Math.Max(rec.str - info.Opacity, 0);
if (dimStr > light) { if (dimStr > light) {
cc.SetBlockSkyLight(x, y, z, dimStr); cc.SetSkyLight(x, y, z, dimStr);
if (info.TransmitsLight) { if (info.TransmitsLight) {
/*spread.Enqueue(new LightRecord(rec.x - 1, rec.y, rec.z, dimStr - 1)); /*spread.Enqueue(new LightRecord(rec.x - 1, rec.y, rec.z, dimStr - 1));
@ -604,7 +604,7 @@ namespace Substrate
x = (x + _blockset.XDim * 2) % _blockset.XDim; x = (x + _blockset.XDim * 2) % _blockset.XDim;
z = (z + _blockset.ZDim * 2) % _blockset.ZDim; z = (z + _blockset.ZDim * 2) % _blockset.ZDim;
BlockInfo info = src.GetBlockInfo(x, y, z); BlockInfo info = src.GetInfo(x, y, z);
if (!info.TransmitsLight) { if (!info.TransmitsLight) {
return info.Luminance; return info.Luminance;
} }
@ -628,12 +628,12 @@ namespace Substrate
x = (x + _blockset.XDim * 2) % _blockset.XDim; x = (x + _blockset.XDim * 2) % _blockset.XDim;
z = (z + _blockset.ZDim * 2) % _blockset.ZDim; z = (z + _blockset.ZDim * 2) % _blockset.ZDim;
BlockInfo info = src.GetBlockInfo(x, y, z); BlockInfo info = src.GetInfo(x, y, z);
if (!info.TransmitsLight) { if (!info.TransmitsLight) {
return BlockInfo.MIN_LUMINANCE; return BlockInfo.MIN_LUMINANCE;
} }
int light = src.GetBlockSkyLight(x, y, z); int light = src.GetSkyLight(x, y, z);
return light; return light;
} }
@ -656,8 +656,8 @@ namespace Substrate
{ {
int light1 = _blockset.GetBlockLight(x1, y1, z1); int light1 = _blockset.GetBlockLight(x1, y1, z1);
int light2 = chunk.GetBlockLight(x2, y2, z2); int light2 = chunk.GetBlockLight(x2, y2, z2);
int lum1 = _blockset.GetBlockInfo(x1, y1, z1).Luminance; int lum1 = _blockset.GetInfo(x1, y1, z1).Luminance;
int lum2 = chunk.GetBlockInfo(x2, y2, z2).Luminance; int lum2 = chunk.GetInfo(x2, y2, z2).Luminance;
int v1 = Math.Max(light1, lum1); int v1 = Math.Max(light1, lum1);
int v2 = Math.Max(light2, lum2); int v2 = Math.Max(light2, lum2);
@ -668,8 +668,8 @@ namespace Substrate
private void TestSkyLight (IBoundedLitBlockCollection chunk, int x1, int y1, int z1, int x2, int y2, int z2) private void TestSkyLight (IBoundedLitBlockCollection chunk, int x1, int y1, int z1, int x2, int y2, int z2)
{ {
int light1 = _blockset.GetBlockSkyLight(x1, y1, z1); int light1 = _blockset.GetSkyLight(x1, y1, z1);
int light2 = chunk.GetBlockSkyLight(x2, y2, z2); int light2 = chunk.GetSkyLight(x2, y2, z2);
if (Math.Abs(light1 - light2) > 1) { if (Math.Abs(light1 - light2) > 1) {
QueueRelight(new BlockKey(x1, y1, z1)); QueueRelight(new BlockKey(x1, y1, z1));

View file

@ -129,27 +129,27 @@ namespace Substrate
_cache.Blocks.SetBlock(x, y, z, block); _cache.Blocks.SetBlock(x, y, z, block);
} }
public BlockInfo GetBlockInfo (int x, int y, int z) public BlockInfo GetInfo (int x, int y, int z)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null || !Check(x, y, z)) { if (_cache == null || !Check(x, y, z)) {
return null; return null;
} }
return _cache.Blocks.GetBlockInfo(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask); return _cache.Blocks.GetInfo(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask);
} }
public int GetBlockID (int x, int y, int z) public int GetID (int x, int y, int z)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null) { if (_cache == null) {
return 0; return 0;
} }
return _cache.Blocks.GetBlockID(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask); return _cache.Blocks.GetID(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask);
} }
public void SetBlockID (int x, int y, int z, int id) public void SetID (int x, int y, int z, int id)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null || !Check(x, y, z)) { if (_cache == null || !Check(x, y, z)) {
@ -159,7 +159,7 @@ namespace Substrate
bool autolight = _cache.Blocks.AutoLight; bool autolight = _cache.Blocks.AutoLight;
_cache.Blocks.AutoLight = _autoLight; _cache.Blocks.AutoLight = _autoLight;
_cache.Blocks.SetBlockID(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, id); _cache.Blocks.SetID(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, id);
_cache.Blocks.AutoLight = autolight; _cache.Blocks.AutoLight = autolight;
} }
@ -184,24 +184,24 @@ namespace Substrate
_cache.Blocks.SetBlock(x, y, z, block); _cache.Blocks.SetBlock(x, y, z, block);
} }
public int GetBlockData (int x, int y, int z) public int GetData (int x, int y, int z)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null) { if (_cache == null) {
return 0; return 0;
} }
return _cache.Blocks.GetBlockData(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask); return _cache.Blocks.GetData(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask);
} }
public void SetBlockData (int x, int y, int z, int data) public void SetData (int x, int y, int z, int data)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null || !Check(x, y, z)) { if (_cache == null || !Check(x, y, z)) {
return; return;
} }
_cache.Blocks.SetBlockData(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, data); _cache.Blocks.SetData(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, data);
} }
#endregion #endregion
@ -234,14 +234,14 @@ namespace Substrate
return _cache.Blocks.GetBlockLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask); return _cache.Blocks.GetBlockLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask);
} }
public int GetBlockSkyLight (int x, int y, int z) public int GetSkyLight (int x, int y, int z)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null) { if (_cache == null) {
return 0; return 0;
} }
return _cache.Blocks.GetBlockSkyLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask); return _cache.Blocks.GetSkyLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask);
} }
public void SetBlockLight (int x, int y, int z, int light) public void SetBlockLight (int x, int y, int z, int light)
@ -254,14 +254,14 @@ namespace Substrate
_cache.Blocks.SetBlockLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, light); _cache.Blocks.SetBlockLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, light);
} }
public void SetBlockSkyLight (int x, int y, int z, int light) public void SetSkyLight (int x, int y, int z, int light)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null || !Check(x, y, z)) { if (_cache == null || !Check(x, y, z)) {
return; return;
} }
_cache.Blocks.SetBlockSkyLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, light); _cache.Blocks.SetSkyLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, light);
} }
public int GetHeight (int x, int z) public int GetHeight (int x, int z)
@ -294,7 +294,7 @@ namespace Substrate
_cache.Blocks.UpdateBlockLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask); _cache.Blocks.UpdateBlockLight(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask);
} }
public void UpdateBlockSkyLight (int x, int y, int z) public void UpdateSkyLight (int x, int y, int z)
{ {
_cache = GetChunk(x, y, z); _cache = GetChunk(x, y, z);
if (_cache == null || !Check(x, y, z)) { if (_cache == null || !Check(x, y, z)) {

View file

@ -56,19 +56,19 @@ namespace Substrate
public BlockInfo Info public BlockInfo Info
{ {
get { return BlockInfo.BlockTable[_container.GetBlockID(_x, _y, _z)]; } get { return BlockInfo.BlockTable[_container.GetID(_x, _y, _z)]; }
} }
public int ID public int ID
{ {
get { return _container.GetBlockID(_x, _y, _z); } get { return _container.GetID(_x, _y, _z); }
set { _container.SetBlockID(_x, _y, _z, value); } set { _container.SetID(_x, _y, _z, value); }
} }
public int Data public int Data
{ {
get { return _container.GetBlockData(_x, _y, _z); } get { return _container.GetData(_x, _y, _z); }
set { _container.SetBlockData(_x, _y, _z, value); } set { _container.SetData(_x, _y, _z, value); }
} }
#endregion #endregion
@ -84,8 +84,8 @@ namespace Substrate
public int SkyLight public int SkyLight
{ {
get { return _container.GetBlockSkyLight(_x, _y, _z); } get { return _container.GetSkyLight(_x, _y, _z); }
set { _container.SetBlockSkyLight(_x, _y, _z, value); } set { _container.SetSkyLight(_x, _y, _z, value); }
} }
#endregion #endregion

View file

@ -196,37 +196,37 @@ namespace Substrate
foreach (ChunkRef chunk in dirty.Values) { foreach (ChunkRef chunk in dirty.Values) {
chunk.Blocks.ResetBlockLight(); chunk.Blocks.ResetBlockLight();
chunk.Blocks.ResetBlockSkyLight(); chunk.Blocks.ResetSkyLight();
} }
foreach (ChunkRef chunk in dirty.Values) { foreach (ChunkRef chunk in dirty.Values) {
chunk.Blocks.RebuildBlockLight(); chunk.Blocks.RebuildBlockLight();
chunk.Blocks.RebuildBlockSkyLight(); chunk.Blocks.RebuildSkyLight();
} }
foreach (ChunkRef chunk in dirty.Values) { foreach (ChunkRef chunk in dirty.Values) {
if (!dirty.ContainsKey(new ChunkKey(chunk.X, chunk.Z - 1))) { if (!dirty.ContainsKey(new ChunkKey(chunk.X, chunk.Z - 1))) {
ChunkRef east = chunk.GetEastNeighbor(); ChunkRef east = chunk.GetEastNeighbor();
chunk.Blocks.StitchBlockLight(east.Blocks, BlockCollectionEdge.EAST); chunk.Blocks.StitchBlockLight(east.Blocks, BlockCollectionEdge.EAST);
chunk.Blocks.StitchBlockSkyLight(east.Blocks, BlockCollectionEdge.EAST); chunk.Blocks.StitchSkyLight(east.Blocks, BlockCollectionEdge.EAST);
} }
if (!dirty.ContainsKey(new ChunkKey(chunk.X, chunk.Z + 1))) { if (!dirty.ContainsKey(new ChunkKey(chunk.X, chunk.Z + 1))) {
ChunkRef west = chunk.GetWestNeighbor(); ChunkRef west = chunk.GetWestNeighbor();
chunk.Blocks.StitchBlockLight(west.Blocks, BlockCollectionEdge.WEST); chunk.Blocks.StitchBlockLight(west.Blocks, BlockCollectionEdge.WEST);
chunk.Blocks.StitchBlockSkyLight(west.Blocks, BlockCollectionEdge.WEST); chunk.Blocks.StitchSkyLight(west.Blocks, BlockCollectionEdge.WEST);
} }
if (!dirty.ContainsKey(new ChunkKey(chunk.X - 1, chunk.Z))) { if (!dirty.ContainsKey(new ChunkKey(chunk.X - 1, chunk.Z))) {
ChunkRef north = chunk.GetNorthNeighbor(); ChunkRef north = chunk.GetNorthNeighbor();
chunk.Blocks.StitchBlockLight(north.Blocks, BlockCollectionEdge.NORTH); chunk.Blocks.StitchBlockLight(north.Blocks, BlockCollectionEdge.NORTH);
chunk.Blocks.StitchBlockSkyLight(north.Blocks, BlockCollectionEdge.NORTH); chunk.Blocks.StitchSkyLight(north.Blocks, BlockCollectionEdge.NORTH);
} }
if (!dirty.ContainsKey(new ChunkKey(chunk.X + 1, chunk.Z))) { if (!dirty.ContainsKey(new ChunkKey(chunk.X + 1, chunk.Z))) {
ChunkRef south = chunk.GetSouthNeighbor(); ChunkRef south = chunk.GetSouthNeighbor();
chunk.Blocks.StitchBlockLight(south.Blocks, BlockCollectionEdge.SOUTH); chunk.Blocks.StitchBlockLight(south.Blocks, BlockCollectionEdge.SOUTH);
chunk.Blocks.StitchBlockSkyLight(south.Blocks, BlockCollectionEdge.SOUTH); chunk.Blocks.StitchSkyLight(south.Blocks, BlockCollectionEdge.SOUTH);
} }
} }
} }