Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkborderman committed Sep 13, 2024
1 parent 29726ef commit be2416a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Tok
} else if(terrain.getPlugin().getClass() == NebulaTerrainPlugin.class){
opts.setEnabled("StarSystemDesignDebrisRemoveOption", true);
} // AsteroidBelt and other ring will not removed because of its sprite will still exist

opts.addOption("Back", "StarSystemDesignDebrisBackOption");
opts.setShortcut("StarSystemDesignDebrisBackOption", Keyboard.KEY_ESCAPE, false, false, false, false);
}else{
Expand All @@ -53,12 +54,11 @@ public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Tok
if(terrain.getPlugin().getClass() == DebrisFieldTerrainPlugin.class){
DebrisFieldTerrainPlugin debris = (DebrisFieldTerrainPlugin)terrain.getPlugin();
debris.getParams().lastsDays = 1f;
dialog.dismiss();
}
else {
Global.getSector().getPlayerFleet().getStarSystem().removeEntity(target);
dialog.dismiss();
}
dialog.dismiss();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
import java.util.Map;

import org.apache.log4j.Logger;
import org.lwjgl.input.Keyboard;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.OptionPanelAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.impl.campaign.rulecmd.BaseCommandPlugin;
import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.campaign.CampaignTerrain;

import mod.starsystemdesign.rulecmd.debris.StarSystemDesignDebrisScript;

Expand All @@ -18,6 +23,35 @@ public class StarSystemDesignEntityScript extends BaseCommandPlugin{

@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
OptionPanelAPI opts = dialog.getOptionPanel();
opts.clearOptions();

String arg = null;
SectorEntityToken target = dialog.getInteractionTarget().getOrbitFocus();
try{
arg = params.get(0).getString(memoryMap);
}catch(IndexOutOfBoundsException e){}

if(arg == null){
opts.addOption("Remove object", "StarSystemDesignDebrisRemoveOption");
opts.setEnabled("StarSystemDesignDebrisRemoveOption", false);
opts.addOption("Back", "StarSystemDesignDebrisRemoveOption");
opts.setShortcut("StarSystemDesignDebrisRemoveOption", Keyboard.KEY_ESCAPE, false, false, false, false);
}else{
switch(arg){
case "remove":{
CampaignTerrain terrain = (CampaignTerrain) target;
if(terrain.getPlugin().getClass() == DebrisFieldTerrainPlugin.class){
DebrisFieldTerrainPlugin debris = (DebrisFieldTerrainPlugin)terrain.getPlugin();
debris.getParams().lastsDays = 1f;
}
else {
Global.getSector().getPlayerFleet().getStarSystem().removeEntity(target);
}
dialog.dismiss();
}
}
}
return true;
}
}

0 comments on commit be2416a

Please sign in to comment.