package data.scripts.world.corvus;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;

import data.scripts.world.BaseSpawnPoint;

public class GRIndySpawnPoint extends BaseSpawnPoint {

	public GRIndySpawnPoint(SectorAPI sector, LocationAPI location, 
							float daysInterval, int maxFleets) {
		super(sector, location, daysInterval, maxFleets, null);
	}

	@Override
	protected CampaignFleetAPI spawnFleet() {
		
		String type = null;
		float r = (float) Math.random();
		if (r > 0.6f) {
			type = "loneMerc";
		} else if (r > 0.25f) {
			type = "merc1";
		} else {
			type = "mercForce";
		}
		        
		float angle = (float) ((float) Math.random() * Math.PI * 2f);
		float x = (float) (Math.cos(angle) * 12000f);
		float y = (float) (Math.sin(angle) * 12000f);
		SectorEntityToken spawnPoint = getLocation().createToken(x, y);
		
		CampaignFleetAPI fleet = getSector().createFleet("independent", type);
		getLocation().spawnFleet(spawnPoint, 0, 0, fleet);
		
		StarSystemAPI system = getSector().getStarSystem("Corvus");
    SectorEntityToken station = system.getEntityByName("Orbital Depot");
		
		fleet.addAssignment(FleetAssignment.RESUPPLY, station, 1000);
			if ((float) Math.random() > 0.4f) {
				fleet.addAssignment(FleetAssignment.PATROL_SYSTEM, null, 30);
			} else {
				fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, station, 15);
			}
		fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, spawnPoint, 1000);
				
		return fleet;
	}

}







