It's long, so warm up those typing fingers.
protected void addPrismMarket(SectorAPI sector)
{
SectorEntityToken prismEntity;
if (ExerelinSetupData.getInstance().numSystems == 1)
{
// FIXME
SectorEntityToken toOrbit = Global.getSector().getEntityById("jangala"); //null;
float radius = toOrbit.getRadius();
float orbitDistance = radius + 150;
if (toOrbit instanceof PlanetAPI)
{
PlanetAPI planet = (PlanetAPI)toOrbit;
if (planet.isStar())
{
orbitDistance = radius + 2000 + rand.nextFloat() * 500;
}
}
prismEntity = toOrbit.getContainingLocation().addCustomEntity("nex_prismFreeport", "Prism Freeport", "exerelin_freeport_type", "independent");
prismEntity.setCircularOrbitPointingDown(toOrbit, ExerelinUtilsAstro.getRandomAngle(rand), orbitDistance, ExerelinUtilsAstro.getOrbitalPeriod(toOrbit, orbitDistance));
}
else
{
LocationAPI hyperspace = sector.getHyperspace();
prismEntity = hyperspace.addCustomEntity("nex_prismFreeport", "Prism Freeport", "exerelin_freeport_type", "independent");
prismEntity.setCircularOrbitWithSpin(hyperspace.createToken(-8005, -4385), ExerelinUtilsAstro.getRandomAngle(rand), 150, 60, 30, 30);
}
prismEntity.addTag(ExerelinConstants.TAG_UNINVADABLE);
/*
EntityData data = new EntityData(null);
data.name = "Prism Freeport";
data.type = EntityType.STATION;
data.forceMarketSize = 4;
MarketAPI market = addMarketToEntity(prismEntity, data, "independent");
*/
MarketAPI market = Global.getFactory().createMarket("nex_prismFreeport" /*+ "_market"*/, "Prism Freeport", 5);
market.setFactionId(Factions.INDEPENDENT);
market.addCondition(Conditions.POPULATION_5);
market.addIndustry(Industries.POPULATION);
market.addIndustry("commerce");
market.addIndustry(Industries.LIGHTINDUSTRY);
market.addIndustry(Industries.MILITARYBASE);
market.addIndustry(Industries.MEGAPORT);
//market.addIndustry(Industries.HEAVYINDUSTRY);
market.addIndustry(Industries.HEAVYBATTERIES);
market.addIndustry(Industries.STARFORTRESS_HIGH);
market.addIndustry(Industries.CRYOSANCTUM);
market.setFreePort(true);
market.addSubmarket(Submarkets.SUBMARKET_OPEN);
market.addSubmarket(Submarkets.GENERIC_MILITARY);
market.addSubmarket(Submarkets.SUBMARKET_BLACK);
market.addSubmarket(Submarkets.SUBMARKET_STORAGE);
market.getMemoryWithoutUpdate().set(ExerelinConstants.MEMORY_KEY_UNINVADABLE, true);
market.getTariff().modifyFlat("generator", sector.getFaction(Factions.INDEPENDENT).getTariffFraction());
ExerelinUtilsMarket.setTariffs(market);
market.addSubmarket("exerelin_prismMarket");
market.setPrimaryEntity(prismEntity);
prismEntity.setMarket(market);
prismEntity.setFaction(Factions.INDEPENDENT);
market.setSurveyLevel(MarketAPI.SurveyLevel.FULL); // not doing this makes market condition tooltips fail to appear
sector.getEconomy().addMarket(market, true);
//prismEntity.removeTag(Tags.STATION); // workaround http://fractalsoftworks.com/forum/index.php?topic=12548.msg213678#msg213678
//pickEntityInteractionImage(prismEntity, market, "", EntityType.STATION);
//prismEntity.setInteractionImage("illustrations", "space_bar");
prismEntity.setCustomDescriptionId("exerelin_prismFreeport");
// deep hyperspace removal (copypasted from UW)
HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);
float minRadius = plugin.getTileSize() * 2f;
float radius = 400;
editor.clearArc(prismEntity.getLocation().x, prismEntity.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
editor.clearArc(prismEntity.getLocation().x, prismEntity.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
}