// generates all chunks that need to be generated void GenerateChunks() { //const int pad = 1; Vector3i playerChunk = WorldUtils.GetChunkPosFromWorldPos(transform.position); if (playerChunk != lastPlayerChunk) { neighborIndex = 0; } lastPlayerChunk = playerChunk; // queue up chunks that failed to load (no save entry) while (JobController.GetGenJobCount() < genJobLimit && chunkGenQueue.Count > 0) { JobController.StartGenerationJob(chunkGenQueue.Dequeue()); } while (neighborIndex < neighborChunks.Length) { if (JobController.GetGenJobCount() >= genJobLimit) { return; } Vector3i p = playerChunk + neighborChunks[neighborIndex]; // add offset Chunk chunk = world.GetChunk(p); if (chunk == null) { world.CreateChunk(p.x, p.y, p.z); } neighborIndex++; } }