package data.scripts.world;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

@SuppressWarnings("unchecked")
public class hadd_ModGen extends SectorGen {

	public void generate(SectorAPI sector) {
		StarSystemAPI system = sector.getStarSystem("Corvus");
		if(system != null) {
	    
			SectorEntityToken token = system.createToken(-13500, 0);
			system.addSpawnPoint(new hadd_ScrapperSpawnPoint(sector, system, 1, 6, token));
			for (int i = 0; i < 3; i++) {
				system.addSpawnPoint(new hadd_ScrapperSpawnPoint(sector, system, 2, 3, token));
			}
			
			SectorEntityToken scrapperStation = system.addOrbitalStation(token, 45, 1, 50, "Scrapyard", "scrappers");
			initScrapyardCargo(sector, scrapperStation);
			
			token = system.createToken(-7500, 15000);
			system.addSpawnPoint(new hadd_ScrapperConvoySpawnPoint(sector, system, 14, 1, token, scrapperStation));
			
			FactionAPI scrappers = sector.getFaction("scrappers");
			
			scrappers.setRelationship("hegemony", -1);
			scrappers.setRelationship("tritachyon", 0);
			scrappers.setRelationship("pirates", -1);
			scrappers.setRelationship("independent", -1);
			scrappers.setRelationship("player", 0);
		}
	}
	
	private void initScrapyardCargo(SectorAPI sector, SectorEntityToken station) {
		CargoAPI cargo = station.getCargo();

		List weaponIds = sector.getAllWeaponIds();
		
		cargo.addWeapons("hadd_dartergun", 8);
		cargo.addWeapons("hadd_flakbombardier", 3);
		cargo.addWeapons("hadd_infernorockets", 5);
		cargo.addWeapons("hadd_microwavebeam", 5);
		cargo.addWeapons("hadd_pointsnap", 10);
		cargo.addWeapons("hadd_shredder", 5);
		cargo.addWeapons("hadd_spines", 8);
		cargo.addWeapons("hadd_spreadchaingun", 5);
		cargo.addWeapons("hadd_volleyrocket", 5);
		cargo.addWeapons("hadd_wrecker", 5);
		cargo.addWeapons("hadd_pointmissiles", 5);
		cargo.addWeapons("hadd_pounderassaultgun", 8);
		cargo.addWeapons("hadd_hellfirerockets", 5);
		cargo.addWeapons("hadd_titancannon", 3);
		cargo.addWeapons("hadd_deathbringer", 5);
		cargo.addWeapons("hadd_dancingblade", 5);
		cargo.addWeapons("hadd_worldshammer", 4);
		cargo.addWeapons("hadd_pyrostorm", 4);
		
		cargo.addCrew(CrewXPLevel.REGULAR, 100);
		cargo.addCrew(CrewXPLevel.GREEN, 1500);
		cargo.addMarines(500);
		cargo.addSupplies(500);
		cargo.addFuel(500);
	
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_battleborn_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_beast_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_bite_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_juggernaut_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_halberd_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_array_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_manta_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_menace_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_refuge_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_striker_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_terra_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_turtle_Hull", null);
		cargo.addMothballedShip(FleetMemberType.SHIP, "hadd_vice_Hull", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_sparrow_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_sparrow_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_bat_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_bat_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_raptor_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_raptor_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_platypus_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_platypus_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_blade_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_blade_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_fang_wing", null);
		cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "hadd_fang_wing", null);
	}
}
