public override void OnSetType(int blockX, int blockY, int blockZ, BlockData.Blocks value) { base.OnSetType(blockX, blockY, blockZ, value); byte blockId = (byte)value; short blockPackedCoords = (short)(blockX << 11 | blockZ << 7 | blockY); if (GrowableBlocks.ContainsKey(blockPackedCoords)) { short unused; if (!BlockHelper.IsGrowable(blockId)) { GrowableBlocks.TryRemove(blockPackedCoords, out unused); } else { byte metaData = GetData(blockX, blockY, blockZ); StructBlock block = new StructBlock(UniversalCoords.FromBlock(Coords.ChunkX, Coords.ChunkZ, blockX, blockY, blockZ), blockId, metaData, World); if (!(BlockHelper.Instance(blockId) as IBlockGrowable).CanGrow(block, this)) { GrowableBlocks.TryRemove(blockPackedCoords, out unused); } } } else { if (BlockHelper.IsGrowable(blockId)) { byte metaData = GetData(blockX, blockY, blockZ); UniversalCoords blockCoords = UniversalCoords.FromBlock(Coords.ChunkX, Coords.ChunkZ, blockX, blockY, blockZ); StructBlock block = new StructBlock(blockCoords, blockId, metaData, World); if ((BlockHelper.Instance(blockId) as IBlockGrowable).CanGrow(block, this)) GrowableBlocks.TryAdd(blockPackedCoords, blockPackedCoords); } } }
public void SetType(int x, int y, int z, BlockData.Blocks value) { this[x, y, z] = (byte)value; }
public override void OnSetType(UniversalCoords coords, BlockData.Blocks value) { base.OnSetType(coords, value); byte blockId = (byte)value; if (GrowableBlocks.ContainsKey(coords.BlockPackedCoords)) { short unused; if (!BlockHelper.IsGrowable(blockId)) { GrowableBlocks.TryRemove(coords.BlockPackedCoords, out unused); } else { StructBlock block = new StructBlock(coords, blockId, GetData(coords), World); if (!(BlockHelper.Instance(blockId) as IBlockGrowable).CanGrow(block, this)) { GrowableBlocks.TryRemove(coords.BlockPackedCoords, out unused); } } } else { if (BlockHelper.IsGrowable(blockId)) { StructBlock block = new StructBlock(coords, blockId, GetData(coords), World); if ((BlockHelper.Instance(blockId) as IBlockGrowable).CanGrow(block, this)) { GrowableBlocks.TryAdd(coords.BlockPackedCoords, coords.BlockPackedCoords); } } } }
public void SetType(UniversalCoords coords, BlockData.Blocks value, bool needsUpdate = true) { this[coords] = (byte)value; OnSetType(coords, value); if(needsUpdate) BlockNeedsUpdate(coords.BlockX, coords.BlockY, coords.BlockZ); }
public void SetType(int blockX, int blockY, int blockZ, BlockData.Blocks value, bool needsUpdate = true) { this[blockX, blockY, blockZ] = (byte)value; OnSetType(blockX, blockY, blockZ, value); if(needsUpdate) BlockNeedsUpdate(blockX, blockY, blockZ); }
public virtual void OnSetType(int blockX, int blockY, int blockZ, BlockData.Blocks value) { }
public virtual void OnSetType(UniversalCoords coords, BlockData.Blocks value) { }
public void SetType(int x, int y, int z, BlockData.Blocks value) { this[x, y, z] = (byte)value; BlockNeedsUpdate(x, y, z); }
public void SetType(int blockX, int blockY, int blockZ, BlockData.Blocks value) { this[blockX, blockY, blockZ] = (byte)value; BlockNeedsUpdate(blockX, blockY, blockZ); }
public void SetType(UniversalCoords coords, BlockData.Blocks value) { this[coords] = (byte)value; BlockNeedsUpdate(coords.BlockX, coords.BlockY, coords.BlockZ); }