public void InitializeGridChunks() { Chunks = new Chunk[m_ChunksWide, m_ChunksHigh, m_ChunksDeep]; m_ChunkProcessor.ChunksAreBeingAdded = true; List <Chunk> newChunksToProcess = new List <Chunk>(); // Add all world chunks to the batch for processing for (int x = LeftChunkBorderColumn; x <= RightChunkBorderColumn; x++) { for (int y = BottomChunkBorderRow; y <= TopChunkBorderRow; y++) { for (int z = 0; z < m_ChunksDeep; z++) { Chunks[x, y, z] = new Chunk(x, y, z, this); Chunks[x, y, z].InitializeBlocks(); newChunksToProcess.Add(Chunks[x, y, z]); m_ChunkProcessor.AddChunkToTerrainQueue(Chunks[x, y, z]); } } } m_ChunkProcessor.AddBatchOfChunks(newChunksToProcess, BatchType.TerrainGeneration); m_ChunkProcessor.AddBatchOfChunks(newChunksToProcess, BatchType.Decoration); m_ChunkProcessor.ChunksAreBeingAdded = false; }
// Regenerates the target chunk first, followed by any others that need regeneration. public void RegenerateChunks(int chunkX, int chunkY, int chunkZ) { m_ChunkProcessor.AddBatchOfChunks(new List <Chunk>() { m_WorldData.Chunks[chunkX, chunkY, chunkZ] }, BatchType.TerrainGeneration); //List<Chunk> chunksNeedingRegeneration = WorldData.ChunksNeedingRegeneration; //if (chunksNeedingRegeneration.Count == 0) //{ // return; //} //Chunk targetChunk = WorldData.Chunks[chunkX, chunkY, chunkZ]; ////Put our target chunk as the first in the list. //if (chunksNeedingRegeneration.Contains(targetChunk)) //{ // chunksNeedingRegeneration.Remove(targetChunk); // chunksNeedingRegeneration.Insert(0, targetChunk); //} //RegenerateChunks(chunksNeedingRegeneration); }