Exemplo 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()));
                }
            }
        }
Exemplo n.º 2
0
 private void Save()
 {
     _saveFile?.Write(_storageKey, StorageValue.Serialize(GetChunkData()));
 }