예제 #1
0
파일: Chunk.cs 프로젝트: dekema2/c-raft
        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);
                }
            }
        }
예제 #2
0
 public void SetType(int x, int y, int z, BlockData.Blocks value)
 {
     this[x, y, z] = (byte)value;
 }
예제 #3
0
파일: Chunk.cs 프로젝트: dekema2/c-raft
        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);
                    }
                }
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 public virtual void OnSetType(int blockX, int blockY, int blockZ, BlockData.Blocks value)
 {
 }
예제 #7
0
 public virtual void OnSetType(UniversalCoords coords, BlockData.Blocks value)
 {
 }
예제 #8
0
 public void SetType(int x, int y, int z, BlockData.Blocks value)
 {
     this[x, y, z] = (byte)value;
     BlockNeedsUpdate(x, y, z);
 }
예제 #9
0
파일: ChunkBase.cs 프로젝트: Smjert/c-raft
 public void SetType(int blockX, int blockY, int blockZ, BlockData.Blocks value)
 {
     this[blockX, blockY, blockZ] = (byte)value;
     BlockNeedsUpdate(blockX, blockY, blockZ);
 }
예제 #10
0
파일: ChunkBase.cs 프로젝트: Smjert/c-raft
 public void SetType(UniversalCoords coords, BlockData.Blocks value)
 {
     this[coords] = (byte)value;
     BlockNeedsUpdate(coords.BlockX, coords.BlockY, coords.BlockZ);
 }