LJLim

Hypershunt generator runcode

Oct 16th, 2021 (edited)
2,841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. runcode import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator;
  2. import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.AddedEntity;
  3. import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.EntityLocation;
  4. import com.fs.starfarer.api.util.WeightedRandomPicker;
  5. import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.StarSystemType;
  6. import com.fs.starfarer.api.impl.campaign.procgen.themes.MiscellaneousThemeGenerator.MakeCoronalTapFaceNearestStar;
  7.  
  8. // set star system name here
  9. StarSystemAPI system = Global.getSector().getStarSystem("Corvus");
  10. String factionId = Factions.NEUTRAL;
  11. Random random = new Random();
  12. AddedEntity entity = null;
  13.  
  14. if (system.getType() == StarSystemType.TRINARY_2CLOSE) {
  15.     EntityLocation loc = new EntityLocation();
  16.     loc.location = new Vector2f();
  17.     entity = BaseThemeGenerator.addEntity(random, system, loc, Entities.CORONAL_TAP, factionId);
  18.     if (entity != null) {
  19.         system.addScript(new MakeCoronalTapFaceNearestStar(entity.entity));
  20.     }
  21. } else {
  22.     WeightedRandomPicker picker = new WeightedRandomPicker();
  23.     WeightedRandomPicker fallback = new WeightedRandomPicker();
  24.     for (PlanetAPI planet : system.getPlanets()) {
  25.         if (!planet.isNormalStar()) continue;
  26.         if (planet.getTypeId().equals(StarTypes.BLUE_GIANT) ||
  27.                 planet.getTypeId().equals(StarTypes.BLUE_SUPERGIANT)) {
  28.             picker.add(planet);
  29.         } else {
  30.             fallback.add(planet);
  31.         }
  32.     }
  33.     if (picker.isEmpty()) {
  34.         picker.addAll(fallback);
  35.     }
  36.  
  37.     PlanetAPI star = (PlanetAPI)picker.pick();
  38.     if (star != null) {
  39.         CustomEntitySpecAPI spec = Global.getSettings().getCustomEntitySpec(Entities.CORONAL_TAP);
  40.         EntityLocation loc = new EntityLocation();
  41.         float orbitRadius = star.getRadius() + spec.getDefaultRadius() + 100f;
  42.         float orbitDays = orbitRadius / 20f;
  43.         loc.orbit = Global.getFactory().createCircularOrbitPointingDown(star, random.nextFloat() * 360f, orbitRadius, orbitDays);
  44.         entity = BaseThemeGenerator.addEntity(random, system, loc, Entities.CORONAL_TAP, factionId);
  45.     }
  46. }
Add Comment
Please, Sign In to add comment