Skip to content

Commit

Permalink
v1.4 update (#3)
Browse files Browse the repository at this point in the history
Scans all gates that are located in systems with at least one non-hidden market at save start
  • Loading branch information
AEROassault committed Jul 18, 2022
1 parent c28d36a commit defb8f9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ScanThoseGates.version
Expand Up @@ -5,9 +5,9 @@
"modVersion":
{
"major":1,
"minor":3,
"minor":4,
#"patch":,
},
"starsectorVersion":"0.95.1a-RC6",
"directDownloadURL":"https://github.com/AEROassault/ScanThoseGates/releases/download/1.3/ScanThoseGates.zip",
"directDownloadURL":"https://github.com/AEROassault/ScanThoseGates/releases/download/v1.4/ScanThoseGates.zip",
}
Binary file modified jars/ScanThoseGates.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions mod_info.json
Expand Up @@ -2,8 +2,8 @@
"id":"scan_those_gates",
"name":"Scan Those Gates",
"author":"AERO",
"version":"1.3",
"description":"Scans all gates that do not have 'Inactive' in their name at the beginning of a save when Nexerelin Skip Story is enabled",
"version":"1.4",
"description":"Scans all gates that are located in systems with at least one non-hidden market at save start",
"gameVersion":"0.95.1a-RC6",
"jars":["jars/ScanThoseGates.jar"],
"modPlugin":"data.scripts.stg_ModPlugin"
Expand Down
Expand Up @@ -2,16 +2,22 @@

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.GateEntityPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.rulecmd.missions.GateCMD;
import exerelin.campaign.ExerelinSetupData;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

public class stg_ModPlugin extends BaseModPlugin {

List<String> systemsWithMarketList = new ArrayList<>();
private static final Logger log = Global.getLogger(stg_ModPlugin.class);

static {log.setLevel(Level.ALL);}
Expand All @@ -20,19 +26,31 @@ public void onNewGameAfterTimePass() {
boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
boolean haveSkipStory = Global.getSettings().getModManager().isModEnabled("skipStory");
if (haveNexerelin || haveSkipStory) {
boolean activateThoseGates = false;
if (haveNexerelin) { activateThoseGates = ExerelinSetupData.getInstance().skipStory; } //check for Nex before variable to avoid crash
if (haveSkipStory) { activateThoseGates = true; } //otherwise, set true if Skip Story is enabled
boolean activateThoseGates;

if (haveNexerelin) { activateThoseGates = ExerelinSetupData.getInstance().skipStory; }
else { activateThoseGates = true; }

if (activateThoseGates) {
for (LocationAPI systemWithMarket : Global.getSector().getEconomy().getStarSystemsWithMarkets()) {
for (MarketAPI market : Global.getSector().getEconomy().getMarkets(systemWithMarket)){
if (!market.isHidden()) {
systemsWithMarketList.add(systemWithMarket.getId());
break;
}
}
}
for (SectorEntityToken gate : Global.getSector().getCustomEntitiesWithTag(Tags.GATE)) {
try {
String gateName = gate.getName();
if (!gateName.contains("Inactive") && !gate.getMemoryWithoutUpdate().getBoolean(GateEntityPlugin.GATE_SCANNED)) {
if (systemsWithMarketList.contains(gate.getContainingLocation().getId())
&& !gate.getMemoryWithoutUpdate().getBoolean(GateEntityPlugin.GATE_SCANNED)) {
gate.getMemory().set(GateEntityPlugin.GATE_SCANNED, true);
log.debug(gateName + " in system " + gate.getContainingLocation().getName() + " is activated.");
GateCMD.notifyScanned(gate);
log.debug(gate.getName() + " in system " + gate.getContainingLocation().getName() + " is activated.");
}
} catch (Exception e) {log.debug(gate.getName() + " in system " + gate.getContainingLocation().getName() + " IS BROKEN.");}
} catch (Exception e) {
log.debug(gate.getName() + " in system " + gate.getContainingLocation().getName() + " IS BROKEN. Exception: " + e);
}
}
}
}
Expand Down

0 comments on commit defb8f9

Please sign in to comment.