package data.scripts.world.systems;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.impl.campaign.procgen.StarAge;
import com.fs.starfarer.api.util.Misc;
import java.awt.*;

public class Aesir
{
    public void generate(SectorAPI sector)
    {
        StarSystemAPI system = sector.createStarSystem("aesir");
        PlanetAPI star = system.initStar("aesir", "aesir", 800.0F, 250.0F);
        star.setCustomDescriptionId("aesir");

        SectorEntityToken alfheimrNebula = Misc.addNebulaFromPNG("data/campaign/terrain/NGO_Aesir.png", 0.0F, 0.0F, system, "terrain", "nebula", 4, 4, StarAge.AVERAGE);
        system.addAsteroidBelt(star, 130, 3250.0F, 160.0F, 65.0F, 75.0F);
        system.addAsteroidBelt(star, 170, 3300.0F, 160.0F, 65.0F, 75.0F);
        system.addAsteroidBelt(star, 150, 3350.0F, 160.0F, 65.0F, 75.0F);
        system.addAsteroidBelt(star, 640, 11800.0F, 355.0F, 465.0F, 475.0F);
        system.addAsteroidBelt(star, 350, 9000.0F, 645.0F, 765.0F, 675.0F);

        PlanetAPI aesir1 = system.addPlanet("breidablik", star, "Breidablik", "planet_breidablik", 120.0F, 140.0F, 1900.0F, 140.0F);
        aesir1.setFaction("new_galactic_order");
        aesir1.setCustomDescriptionId("breidablik");
        aesir1.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "barren"));
        aesir1.getSpec().setGlowColor(new Color(255, 125, 0, 155));
        aesir1.applySpecChanges();
        aesir1.setInteractionImage("illustrations", "town_background");
        aesir1.setCustomDescriptionId("breidablik");

        PlanetAPI aesir2 = system.addPlanet("adelgis", star, "Adelgis", "gas_giant", 310.0F, 280.0F, 4300.0F, 170.0F);
        aesir2.setCustomDescriptionId("adelgis");
        aesir2.getSpec().setPlanetColor(new Color(147, 158, 126, 255));
        aesir2.getSpec().setAtmosphereColor(new Color(182, 129, 134, 200));
        aesir2.getSpec().setCloudColor(new Color(221, 42, 234, 200));
        aesir2.getSpec().setTilt(18.0F);
        aesir2.applySpecChanges();

        PlanetAPI aesir3 = system.addPlanet("rando", star, "Muspelheim", "rocky_unstable", 270.0F, 90.0F, 6450.0F, 190.0F);
        aesir3.setFaction("pirates");
        aesir3.setCustomDescriptionId("rando");
        aesir3.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "barren"));
        aesir3.getSpec().setGlowColor(new Color(245, 255, 200, 255));
        aesir3.applySpecChanges();

        PlanetAPI aesir4 = system.addPlanet("berngar", star, "Berngar", "jungle", 320.0F, 110.0F, 2700.0F, 110.0F);
        aesir4.setFaction("independent");
        aesir4.setCustomDescriptionId("berngar");
        aesir4.getSpec().setPlanetColor(new Color(71, 71, 0, 255));
        aesir4.getSpec().setAtmosphereColor(new Color(133, 133, 102, 200));
        aesir4.getSpec().setCloudColor(new Color(218, 218, 209, 220));
        aesir4.getSpec().setTilt(12.0F);

        SectorEntityToken relay = system.addCustomEntity("listening_post", "NGO Relay Station", "comm_relay", "new_galactic_order");
        relay.setCircularOrbit(system.getEntityById("aesir"), 770.0F, 10350.0F, 110.0F);

        SectorEntityToken ngo_station = system.addCustomEntity("ngo_station", "Himinbjoerg", "ngo_station", "new_galactic_order");
        ngo_station.setCircularOrbitPointingDown(system.getEntityById("breidablik"), 320.0F, 300.0F, 30.0F);
        SectorEntityToken breida = system.getEntityById("breidablik");

        SectorEntityToken ngo_station2 = system.addCustomEntity("ngo_station2", "Valgrind", "ngo_station2", "new_galactic_order");
        ngo_station2.setCircularOrbitPointingDown(system.getEntityById("adelgis"), 360.0F, 575.0F, 40.0F);
        SectorEntityToken adelgi = system.getEntityById("adelgis");

        SectorEntityToken ngo_station3 = system.addCustomEntity("ngo_station3", "Old Station", "ngo_station3", "independent");
        ngo_station3.setCircularOrbitPointingDown(system.getEntityById("aesir"), 30.0F, 8600.0F, 360.0F);

        system.getLocation().set(12200.0F, -2800.0F);
        system.setBackgroundTextureFilename("graphics/NGO/backgrounds/Aesir_background.jpg");
        system.setLightColor(new Color(255, 98, 0));
        system.addRingBand(aesir2, "misc", "rings_adelgis", 256.0F, 2, Color.GRAY, 256.0F, 400.0F, 40.0F);

        JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("aesir_gate", "Aesir Gate");
        OrbitAPI orbit = Global.getFactory().createCircularOrbit(aesir1, 0.0F, 500.0F, 80.0F);
        jumpPoint.setOrbit(orbit);
        jumpPoint.setRelatedPlanet(aesir1);
        jumpPoint.setStandardWormholeToHyperspaceVisual();
        system.addEntity(jumpPoint);

        system.autogenerateHyperspaceJumpPoints(true, true);
    }
}
