package eu.mhsl.minenet.minigames.world.generator.terrain;

import eu.mhsl.minenet.minigames.world.generator.structures.Structure;
import net.minestom.server.instance.generator.GenerationUnit;
import net.minestom.server.instance.generator.Generator;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseGenerator implements Generator {
    private final List<Structure> structures = new ArrayList<>();
    private final List<Generator> mixIns = new ArrayList<>();

    public void addStructure(Structure structure) {
        this.structures.add(structure);
    }

    public void addMixIn(Generator mixIn) {
        this.mixIns.add(mixIn);
    }

    protected void applyStructures(GenerationUnit unit) {
        structures.forEach(structure -> unit.fork(structure::generateStructure));
    }


    @Override
    public void generate(@NotNull GenerationUnit unit) {
        mixIns.forEach(generator -> generator.generate(unit));
    }
}
