예제 #1
0
        public ChunkSection PlaceBlock(Coord3 worldPos, BlockData data, bool updateChunk = true)
        {
            var sectionPos = worldPos.WorldToChunk();
            var section    = chunks.GetSection(sectionPos);

            if (section == null)
            {
                return(null);
            }

            section.blocks.PlaceBlock(worldPos.WorldToBlock(section.worldPosition), data, updateChunk);
            return(section);
        }
예제 #2
0
        public Block GetBlock(Coord3 pos)
        {
            var chunkPos = pos.WorldToChunk();
            var chunk    = chunks.GetSection(chunkPos);

            if (chunk == null)
            {
                return(null);
            }

            var blockPos = pos.WorldToBlock(chunk.worldPosition);

            return(chunk.blocks.GetBlock(blockPos));
        }
예제 #3
0
        public Block GetBlock(RaycastHit hit, bool adjacent = false)
        {
            var pos = Coord3.RaycastToBlock(hit, adjacent);

            return(GetBlock(pos));
        }
예제 #4
0
        public ChunkSection PlaceBlock(RaycastHit hit, BlockData data, out Block block, bool adjacent = false)
        {
            var pos = Coord3.RaycastToBlock(hit, adjacent);

            return(PlaceBlock(pos, data, out block, true));
        }