示例#1
0
        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;
            }
        }