package eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.enemies;

import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.TowerdefenseRoom;
import net.minestom.server.MinecraftServer;
import net.minestom.server.timer.TaskSchedule;

public record GroupFactory(EnemyFactory enemyFactory, int count, long delay) {
    public void summonGroup(TowerdefenseRoom instance) {
        for (int i = 0; i < this.count; i++) {
            MinecraftServer.getSchedulerManager().scheduleTask(() -> {
                instance.addEnemy(this.enemyFactory.buildEntity());
                return TaskSchedule.stop();
            }, TaskSchedule.millis(this.delay*i));
        }
    }
}
