package data.scripts.world;

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;

public class MercenarySpawnPoint extends BaseSpawnPoint 
{
 public MercenarySpawnPoint(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 > .75f) type = "mercenary1";
	 else if (r > .45f) type = "mercenary2";
	 else if (r > .15f) type = "mercenary3";
	 else if (r > .5f) type = "mercenary4";
	 else type = "mercenary5";

	 float angle = (float) ((float) Math.random() * Math.PI * 2f);
	 float x = (float) (Math.cos(angle) * 15000f);
	 float y = (float) (Math.sin(angle) * 15000f);
	 SectorEntityToken spawnPoint = getLocation().createToken(x, y);

	 CampaignFleetAPI fleet = getSector().createFleet("mercenary", type);
	 getLocation().spawnFleet(spawnPoint, 0, 0, fleet);
	 fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 1000);

	 return fleet;
	}

}