예제 #1
0
파일: Overworld.cs 프로젝트: Tobi406/SM3
        public Chunk?GetChunk(ChunkPosition position)
        {
            if (_chunks.TryGetValue(position, out var v))
            {
                return(v);
            }

            return(null);
        }
예제 #2
0
파일: Overworld.cs 프로젝트: Tobi406/SM3
        public Chunk Load(ChunkPosition position)
        {
            if (_chunks.TryGetValue(position, out var v))
            {
                return(v);
            }

            Memory <BlockState> blockStates = new BlockState[Chunk.Width * Chunk.Height * Chunk.Depth];
            Memory <byte>       skylight    = new byte[Chunk.Width * Chunk.Height * Chunk.Depth / 2];
            Memory <byte>       blocklight  = new byte[Chunk.Width * Chunk.Height * Chunk.Depth / 2];


            var chunk = new Chunk(blockStates,
                                  skylight,
                                  blocklight);

            GenerateChunk(chunk);

            _chunks[position] = chunk;
            return(chunk);
        }