Skip to content

Commit

Permalink
Merge pull request #11 from Tranquiliti/dev
Browse files Browse the repository at this point in the history
Update v2.1.2
  • Loading branch information
Tranquiliti authored Aug 31, 2024
2 parents 82410db + 3301e56 commit c3bd7ce
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 36 deletions.
14 changes: 14 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Version 2.1.2

* "type" option for "star" and "planet" entities can now accept a list of star/planet types
- A random star/planet type from the list will be selected when generating the entity
- Default custom star system now uses this "type" option for both its star and the Barren planet
- Removed "random_star_giant" as a type since it is no longer needed
* Default custom star system no longer contains a research station
* "Generate custom star systems" LunaSnippet now creates a debug button if customStarSystems.json is malformed
- The exact JSON error will be shown when executing the LunaSnippet again with the button selected
* Added missing particle effects for "coronal_tap" entities created outside the "addCoronalHypershunt" option
* Minor code refactors



Version 2.1.1

* Added "numAsteroids" option for "asteroid_field" and "asteroid_belt" entities
Expand Down
4 changes: 2 additions & 2 deletions customizablestarsystems.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{
"major":2,
"minor":1,
"patch":1
"patch":2
},
"starsectorVersion":"0.97a-RC11",
"directDownloadURL":"https://github.com/Tranquiliti/CustomizableStarSystems/releases/download/v2.1.1/CustomizableStarSystems-v2.1.1.zip",
"directDownloadURL":"https://github.com/Tranquiliti/CustomizableStarSystems/releases/download/v2.1.2/CustomizableStarSystems-v2.1.2.zip",
"changelogURL":"https://raw.githubusercontent.com/Tranquiliti/CustomizableStarSystems/main/changelog.txt"
}
5 changes: 2 additions & 3 deletions data/config/customStarSystems.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"entities":[
{
"entity":"star",
"type":"random_star_giant"
"type":["star_blue_giant","star_blue_supergiant","star_orange_giant","star_red_supergiant","star_red_giant"]
},
{
"entity":"planet",
Expand All @@ -46,7 +46,7 @@
},
{
"entity":"planet",
"type":"barren",
"type":["barren","barren2","barren3"],
"orbitRadius":6420,
"radius":120,
"conditions":["no_atmosphere","ore_sparse","rare_ore_sparse"]
Expand All @@ -55,7 +55,6 @@
{"entity":"inactive_gate","orbitRadius":5250},
{"entity":"jump_point","orbitRadius":6840,"name":"Fringe Jump-point"},
{"entity":"magnetic_field","orbitRadius":325,"focus":1,"size":200},
{"entity":"station_research","orbitRadius":425,"focus":1},
{"entity":"stable_location","focus":[1,4]},
{"entity":"stable_location","focus":[1,5]},
{"entity":"comm_relay","focus":[2,4]}
Expand Down
13 changes: 10 additions & 3 deletions data/config/referenceStarSystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@

# Type of star to make
# Star IDs are found in starsector-core/data/campaign/procgen/star_gen_data.csv
# "random_star_giant" chooses a random vanilla star giant
#
# Can also be an array of star IDs (e.g. ["star_id_1","star_id_2",...]),
# where a random star type will be chosen when generating the star.
#
# WARNING: Nebulas are not supported
# Defaults to "star_red_dwarf" if this entry is omitted
"type":"random_star_giant",
"type":"star_red_dwarf",

# Name of this entity
# If this entity is the first star in the "entities" list, it will also change this system's name
Expand Down Expand Up @@ -181,7 +184,7 @@
},
{ # A star NOT in the system center
"entity":"star",
"type":"random_star_giant",
"type":["star_orange_giant","star_red_giant","star_blue_giant"],
"name":"Placeholder Star",
"radius":0,
"coronaRadius":0,
Expand Down Expand Up @@ -235,6 +238,10 @@

# Type of planet to make
# Planet IDs are found in starsector-core/data/campaign/procgen/planet_gen_data.csv
#
# Can also be an array of planet IDs (e.g. ["planet_id_1","planet_id_2",...]),
# where a random planet type will be chosen when generating the planet.
#
# Defaults to "barren" if this entry is omitted
"type":"barren",

Expand Down
1 change: 0 additions & 1 deletion data/strings/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"path_graphics_planet":"graphics/planets/",
"path_graphics_background":"graphics/backgrounds/",
"path_merged_json_customStarSystems":"data/config/customStarSystems.json",
"type_random_star_giant":"random_star_giant",

# Names used for entities
"name_mirror1":"Stellar Mirror Alpha",
Expand Down
Binary file modified jars/CustomizableStarSystems.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion mod_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name":"Customizable Star Systems",
"author":"Tranquility",
"utility":"true",
"version":{"major":2,"minor":1,"patch":1},
"version":{"major":2,"minor":1,"patch":2},
"description":"Adds customizable star systems, editable through a JSON config file.",
"gameVersion":"0.97a-RC11",
"jars":["jars/CustomizableStarSystems.jar"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public final class CSSStrings {
public static final String PATH_GRAPHICS_PLANET = Global.getSettings().getString(STRINGS_CATEGORY, "path_graphics_planet");
public static final String PATH_GRAPHICS_BACKGROUND = Global.getSettings().getString(STRINGS_CATEGORY, "path_graphics_background");
public static final String PATH_MERGED_JSON_CUSTOM_STAR_SYSTEMS = Global.getSettings().getString(STRINGS_CATEGORY, "path_merged_json_customStarSystems");
public static final String TYPE_RANDOM_STAR_GIANT = Global.getSettings().getString(STRINGS_CATEGORY, "type_random_star_giant");

// Names used in Solar Array generation
public static final String NAME_MIRROR1 = Global.getSettings().getString(STRINGS_CATEGORY, "name_mirror1");
Expand Down
54 changes: 30 additions & 24 deletions src/org/tranquility/customizablestarsystems/CustomStarSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,38 @@
/**
* A custom star system
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "FieldCanBeLocal"})
public class CustomStarSystem {
// Default values
public static final int DEFAULT_NUMBER_OF_SYSTEMS = 1;
private final int DEFAULT_SET_TO_PROC_GEN = -1; // For user's sake, referenceStarSystem.json uses 0 to specify proc-gen
private final int DEFAULT_MARKET_SIZE = 0;

// These variables are not static since this code usually runs once and then never again during gameplay
// They are also not local to make tracking down Strings easier for externalization purposes
// Entities, usually used in switch cases
public final String ENTITY_EMPTY_LOCATION = "empty_location";
public final String ENTITY_REMNANT_STATION = "remnant_station";
public final String ENTITY_RINGS_ICE = "rings_ice0";
public final String ENTITY_RINGS_DUST = "rings_dust0";
public final String ENTITY_RINGS_SPECIAL = "rings_special0";
public final String ENTITY_RINGS_ASTEROIDS = "rings_asteroids0";
private final String ENTITY_EMPTY_LOCATION = "empty_location";
private final String ENTITY_REMNANT_STATION = "remnant_station";
private final String ENTITY_RINGS_ICE = "rings_ice0";
private final String ENTITY_RINGS_DUST = "rings_dust0";
private final String ENTITY_RINGS_SPECIAL = "rings_special0";
private final String ENTITY_RINGS_ASTEROIDS = "rings_asteroids0";

// Dev/internal ids
public final String ID_SYSTEM = "system_"; // Most system entity ids should start with this
public final String ID_STAR = ":star_";
public final String ID_PLANET = ":planet_";
public final String ID_STATION = ":station_";
public final String ID_MARKET = "market_";
public final String CONDITION_POPULATION = "population_"; // addMarket() appends a number to this
private final String ID_SYSTEM = "system_"; // Most system entity ids should start with this
private final String ID_STAR = ":star_";
private final String ID_PLANET = ":planet_";
private final String ID_STATION = ":station_";
private final String ID_MARKET = "market_";
private final String CONDITION_POPULATION = "population_"; // addMarket() appends a number to this

// addRemnantStation() strings
public final String ID_REMNANT_STATION_DAMAGED = "remnant_station2_Damaged";
public final String ID_REMNANT_STATION_STANDARD = "remnant_station2_Standard";
public final String MEMFLAGS_DAMAGED_STATION = "$damagedStation";
private final String ID_REMNANT_STATION_DAMAGED = "remnant_station2_Damaged";
private final String ID_REMNANT_STATION_STANDARD = "remnant_station2_Standard";
private final String MEMFLAGS_DAMAGED_STATION = "$damagedStation";

// Other
private ArrayList<Constellation> procGenConstellations; // Filled in during 1st setLocation() call
private final String[] RANDOM_STAR_GIANT_TYPES = {StarTypes.ORANGE_GIANT, StarTypes.RED_GIANT, StarTypes.RED_SUPERGIANT, StarTypes.BLUE_GIANT, StarTypes.BLUE_SUPERGIANT};
private final Random randomSeed = StarSystemGenerator.random; // Sector seed
private final HashMap<MarketAPI, String> marketsToOverrideAdmin = new HashMap<>(); // Updated in CustomStarSystem.addMarket()

Expand Down Expand Up @@ -347,9 +348,10 @@ private int addCenterStars(JSONArray entities) throws JSONException {
}

private PlanetAPI addStar(JSONObject options, int index, boolean isClose) throws JSONException {
String starType = options.optString(OPT_TYPE, DEFAULT_STAR_TYPE);
if (starType.equals(TYPE_RANDOM_STAR_GIANT))
starType = RANDOM_STAR_GIANT_TYPES[randomSeed.nextInt(RANDOM_STAR_GIANT_TYPES.length)];
JSONArray typeList = options.optJSONArray(OPT_TYPE);
String starType;
if (typeList != null) starType = typeList.getString(randomSeed.nextInt(typeList.length()));
else starType = options.optString(OPT_TYPE, DEFAULT_STAR_TYPE);

StarGenDataSpec starData = (StarGenDataSpec) Global.getSettings().getSpec(StarGenDataSpec.class, starType, true);
if (starData == null)
Expand Down Expand Up @@ -416,7 +418,11 @@ private PlanetAPI addStar(JSONObject options, int index, boolean isClose) throws
}

private PlanetAPI addPlanet(JSONObject options, int index) throws JSONException {
String planetType = options.optString(OPT_TYPE, DEFAULT_PLANET_TYPE);
JSONArray typeList = options.optJSONArray(OPT_TYPE);
String planetType;
if (typeList != null) planetType = typeList.getString(randomSeed.nextInt(typeList.length()));
else planetType = options.optString(OPT_TYPE, DEFAULT_PLANET_TYPE);

PlanetGenDataSpec planetData = (PlanetGenDataSpec) Global.getSettings().getSpec(PlanetGenDataSpec.class, planetType, true);
if (planetData == null)
throw new IllegalArgumentException(String.format(ERROR_PLANET_TYPE_NOT_FOUND, planetType, SYSTEM_ID, index));
Expand Down Expand Up @@ -648,6 +654,7 @@ private SectorEntityToken addCustomEntity(JSONObject options) throws JSONExcepti
entity.getMemoryWithoutUpdate().set(MemFlags.OBJECTIVE_NON_FUNCTIONAL, true);
break;
case Entities.CORONAL_TAP:
system.addScript(new CoronalTapParticleScript(entity));
system.addTag(Tags.HAS_CORONAL_TAP);
system.addTag(Tags.THEME_INTERESTING);
break;
Expand Down Expand Up @@ -967,14 +974,13 @@ private void generateCoronalHypershuntIfApplicable() {
float orbitRadius = systemCenter.getRadius() + hypershunt.getRadius() + 100f;
hypershunt.setCircularOrbitPointingDown(systemCenter, randomSeed.nextFloat() * 360f, orbitRadius, orbitRadius / 20f);
} else { // Stay in the center, facing towards the primary star
PlanetAPI primaryStar = system.getStar();
hypershunt.setCircularOrbitPointingDown(primaryStar, (primaryStar.getCircularOrbitAngle() - 180f) % 360f, primaryStar.getCircularOrbitRadius(), primaryStar.getCircularOrbitPeriod());
hypershunt.setLocation(0, 0); // May not be necessary, but better safe than sorry
system.addScript(new MiscellaneousThemeGenerator.MakeCoronalTapFaceNearestStar(hypershunt));
}

if (!hasFactionPresence) makeDiscoverable(hypershunt, 3500f);

system.addScript(new CoronalTapParticleScript(hypershunt));

system.addTag(Tags.HAS_CORONAL_TAP);
system.addTag(Tags.THEME_INTERESTING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void addParameters(SnippetBuilder builder) {
JSONObject systems;
try {
systems = CSSUtil.getMergedSystemJSON();
} catch (Exception e) {
} catch (Exception e) { // This signifies a JSON error, so it does not matter if the "button" looks ugly
builder.addBooleanParameter(COMMANDS_ERROR_BAD_JSON, COMMANDS_ERROR_BAD_JSON, true);
return;
}

Expand Down

0 comments on commit c3bd7ce

Please sign in to comment.