private Chunk LoadChunk(int x, int z) { lock (ChunkGenLock) { Chunk chunk = new Chunk(this, x << 4, z << 4); if (chunk.Load()) Chunks.Add(chunk); else chunk = Generator.ProvideChunk(x, z); return chunk; } }
private Chunk LoadChunk(UniversalCoords coords, bool create, bool recalculate) { lock (ChunkGenLock) { Chunk chunk = new Chunk(this, coords); if (chunk.Load()) AddChunk(chunk); else if (create) chunk = Generator.ProvideChunk(coords.ChunkX, coords.ChunkZ, chunk, recalculate); else chunk = null; return chunk; } }
private Chunk LoadChunk(UniversalCoords coords, bool create, bool recalculate) { lock (ChunkGenLock) { // We should check again since two threads can enter here, one after the other, with the same chunk to load Chunk chunk; if ((chunk = Chunks[coords]) != null) return chunk; chunk = new Chunk(this, coords); if (chunk.Load()) AddChunk(chunk); else if (create) _generator.ProvideChunk(coords.ChunkX, coords.ChunkZ, chunk, recalculate); else chunk = null; if(chunk != null) chunk.InitGrowableCache(); return chunk; } }
private Chunk LoadChunk(int x, int z, bool create, bool recalculate) { lock (ChunkGenLock) { Chunk chunk = new Chunk(this, x, z); if (chunk.Load()) AddChunk(chunk); else if (create) chunk = Generator.ProvideChunk(x, z, chunk, recalculate); else chunk = null; return chunk; } }