import { GdRoot } from "../../data/GdRoot";
import { SimLevel } from "../SimLevel";
import { SimMain } from "../SimMain";
import { SimCommand } from "./SimCommand";

export class SimCommandStartNextWave extends SimCommand {

    execute(simMain: SimMain) {
        const level = simMain.currentLevel;
        if (!level) return;

        const data = simMain.gdRoot.levels[level.index];
        level.currentWave += 1;
        if (!data.waves[level.currentWave]) {
            level.paused = true;
            return;
        }
        level.nextWaveStep = level.currentStep + simMain.gdRoot.simulation.waveDuration * simMain.gdRoot.simulation.stepsPerSecond - 1;
        level.lastEnemySpawnStep = level.currentStep;
        level.enemiesLeftToSpawn = data.waves[level.currentWave].amount;
    }
}
