package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import data.scripts.world.NGOGen;
import exerelin.campaign.SectorManager;
import org.dark.shaders.light.LightData;
import org.dark.shaders.util.ShaderLib;
import org.dark.shaders.util.TextureData;

public class NGOModPlugin extends BaseModPlugin
{
    public static boolean hasGraphicsLib;
    public static boolean hasLazyLib;

    public void onApplicationLoad() throws ClassNotFoundException
    {
        hasGraphicsLib = Global.getSettings().getModManager().isModEnabled("shaderLib");
        hasLazyLib = Global.getSettings().getModManager().isModEnabled("lw_lazylib");

        if (hasGraphicsLib) {
            ShaderLib.init();
            LightData.readLightDataCSV("data/lights/ngo_light_data.csv");
            TextureData.readTextureDataCSV("data/lights/ngo_texture_data.csv");
        }
        if (hasLazyLib) {
            Global.getSettings().getScriptClassLoader().loadClass("org.lazywizard.lazylib.ModUtils");
        }
    }

    public void onNewGame()
    {
        boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
        if ((!haveNexerelin) || (SectorManager.getCorvusMode())) {
            new NGOGen().generate(Global.getSector());
        }
    }
}
