Esempio n. 1
0
        public ushort this[BlockPos p]
        {
            get
            {
                if (p.Y < -200)
                {
                    return 1;
                }

                var chunk = PeekChunk((ChunkPos)p);
                if (chunk == null)
                {
                    return 0;
                }

                return chunk[p.X & _chunkMask, p.Y & _chunkMask, p.Z & _chunkMask];
            }

            set
            {
                var chunkPos = (ChunkPos)p;
                var chunk = GetChunk(chunkPos);
                if (chunk.IsCreated)
                {
                    chunk[p.X & _chunkMask, p.Y & _chunkMask, p.Z & _chunkMask] = value;
                    Universe?.SaveFile?.Write(StorageKey.Get("ChunkData", chunkPos), StorageValue.Serialize(chunk.GetChunkData()));
                }
            }
        }
Esempio n. 2
0
 private static double FindHeight(World world, BlockPos blockPos)
 {
     if (world[blockPos] != 0) return 1;
     if (world[blockPos] == 0 && world[blockPos - BlockOffset.UnitY] == 0) return -1;
     return 0;
 }
Esempio n. 3
0
        private static bool AllPassable(World world, BlockPos block0, BlockPos block1)
        {
            for (int x = block0.X; x <= block1.X; ++x)
            {
                for (int y = block0.Y; y <= block1.Y; ++y)
                {
                    for (int z = block0.Z; z <= block1.Z; ++z)
                    {
                        var blockPos = new BlockPos(x, y, z);
                        var chunk = world.GetChunk((ChunkPos)blockPos);

                        if (!chunk.IsCreated) return false;

                        if (world[blockPos] != 0)
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }