Exemplo n.º 1
0
        private void GenerateNextChunk(bool fast, int worker)
        {
            if (!loadOrder.HasNext())
            {
                return;
            }

            GetPlayerChunk();

            int chunkX, chunkY, chunkZ;

            for (int i = 0; i < 10; i++)
            {
                ChunkOffset offset = loadOrder.NextPosition();

                chunkX = offset.x + lastChunkX;
                chunkY = offset.y + lastChunkY;
                chunkZ = offset.z + lastChunkZ;

                if (forceRegenerateChunks || world.GetChunkByCoords(chunkX, chunkY, chunkZ, false) == null)
                {
                    genTasks[worker].SetupChunk(chunkX, chunkY, chunkZ);
                    if (fast)
                    {
                        genTasks[worker].PrepareTask();
                        genTasks[worker].RunTask();
                        genTasks[worker].FinishTask();
                    }
                    else
                    {
                        workers[worker].AddTaskToQueue(genTasks[worker]);
                    }

                    break;
                }
            }
        }