public Chunk?GetChunk(ChunkPosition position) { if (_chunks.TryGetValue(position, out var v)) { return(v); } return(null); }
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); }