void Update() { if (!playerLastChunkCoord.Equals(GetChunkCoord(player.position))) { CheckViewDistance(); playerLastChunkCoord = GetChunkCoord(player.position); worldGen.AttemptToSpawnStructures(); } if (chunksToCreate.Count > 0) { ChunkCoord cc = chunksToCreate[0]; chunksToCreate.RemoveAt(0); activeChunks.Add(cc); chunks[cc.x, cc.z].Init(); } if (subchunksToDraw.Count > 0) { lock (subchunksToDraw) { for (int i = 0; i < PerformanceSettings.subchunksToDrawPerFrame; i++) { if (subchunksToDraw.Count == 0) { break; } if (GetSubchunk(subchunksToDraw.Peek()).isEditable) { GetSubchunk(subchunksToDraw.Dequeue()).CreateMesh(); } } } } }