diff --git a/src/mod/starsystemdesign/rulecmd/debris/StarSystemDesignDebrisScript.java b/src/mod/starsystemdesign/rulecmd/debris/StarSystemDesignDebrisScript.java index 71e733c..50c4b27 100644 --- a/src/mod/starsystemdesign/rulecmd/debris/StarSystemDesignDebrisScript.java +++ b/src/mod/starsystemdesign/rulecmd/debris/StarSystemDesignDebrisScript.java @@ -44,6 +44,7 @@ public boolean execute(String ruleId, InteractionDialogAPI dialog, List params, Map 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; } }