import { WorldChunk } from "../WorldChunk/WorldChunk";
import { fillChunk } from "./WorldGeneration";

let chunkFillQueue = [];
let currentChunkIndex = -1;

/**
 * 
 * @param {WorldChunk} chunk 
 */
export function addChunkToFillQueue(chunk, x, y)
{
    chunkFillQueue.push({chunk, x, y});
    currentChunkIndex++;
}

export function handleChunkFilling(tick) {
    // console.log(tick.deltaMS);
    if(currentChunkIndex < 0) return;
    fillChunk(chunkFillQueue[currentChunkIndex].chunk, chunkFillQueue[currentChunkIndex].x, chunkFillQueue[currentChunkIndex].y);
    chunkFillQueue.pop();
    currentChunkIndex--;

}
