1package com.fs.starfarer.api.impl.campaign;
4import java.util.HashMap;
7import org.lwjgl.input.Keyboard;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.CampaignFleetAPI;
11import com.fs.starfarer.api.campaign.CargoAPI;
12import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
13import com.fs.starfarer.api.campaign.InteractionDialogAPI;
14import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
15import com.fs.starfarer.api.campaign.OptionPanelAPI;
16import com.fs.starfarer.api.campaign.PlanetAPI;
17import com.fs.starfarer.api.campaign.SpecialItemData;
18import com.fs.starfarer.api.campaign.StarSystemAPI;
19import com.fs.starfarer.api.campaign.TextPanelAPI;
20import com.fs.starfarer.api.campaign.VisualPanelAPI;
21import com.fs.starfarer.api.campaign.rules.MemKeys;
22import com.fs.starfarer.api.campaign.rules.MemoryAPI;
23import com.fs.starfarer.api.combat.EngagementResultAPI;
24import com.fs.starfarer.api.impl.campaign.ids.Commodities;
25import com.fs.starfarer.api.impl.campaign.ids.Items;
26import com.fs.starfarer.api.impl.campaign.ids.Sounds;
27import com.fs.starfarer.api.impl.campaign.intel.events.ht.HTNonASBScanFactor;
28import com.fs.starfarer.api.impl.campaign.intel.events.ht.HTPoints;
29import com.fs.starfarer.api.impl.campaign.intel.events.ht.HyperspaceTopographyEventIntel;
30import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
31import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
32import com.fs.starfarer.api.impl.campaign.rulecmd.DumpMemory;
33import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption;
34import com.fs.starfarer.api.loading.Description;
35import com.fs.starfarer.api.loading.Description.Type;
36import com.fs.starfarer.api.util.Misc;
45 public static String
ADDED_KEY =
"$core_starAddedStable";
47 private static enum OptionId {
53 DUMP_PLANETKILLER_ON_SECOND_THOUGHT,
54 DUMP_PLANETKILLER_CONT_1,
55 ADD_STABLE_NEVER_MIND,
66 private boolean unpauseOnExit =
true;
73 this.unpauseOnExit = unpauseOnExit;
116 if (optionData ==
null)
return;
119 Map<String, MemoryAPI> memoryMap =
new HashMap<String, MemoryAPI>();
143 OptionId option = (OptionId) optionData;
150 String type =
"star";
151 String corona =
"star's corona";
152 String corona2 =
"in the star's corona";
155 corona =
"event horizon";
156 corona2 =
"near the event horizon";
163 addText(getString(
"approach"));
169 addText(
"Your sensors officer hesitates, then calls for your attention. \"Captain, there's a... pattern. "
170 +
"From the black hole. Or, rather,\" they pause, looking almost embarrassed. \"-The energy radiated"
171 +
" by the accretion disc."
173 +
"They pull a collated sensor output map into the primary holo. \"It's almost a signal. See, if we "
174 +
"chart these fluctuations in energy output over time..."
176 +
"You see it now, an orderly series. Not quite a sequence of prime numbers, "
177 +
"unless you jig the math. Statistically this is nearly impossible. Possible explanations "
178 +
"are as unlikely: a series of planets - large moons? - with specific mass-ratio relationships, "
179 +
"all pulled into the accretion disc at just such an angle, like an intentional "
180 +
"message... or orderly annihilation of a constructed planetary system at a scale beyond the wildest "
181 +
"dreams of the most bloody-minded war-planners of the Domain."
183 +
"It can't be known. The pattern disappears as quickly as it arose.");
188 new HTNonASBScanFactor(
"Picked up unusual readings from abyssal black hole", points), dialog);
191 addText(
"Your sensors officer detects no more unusual energy patterns from the inner rim of the accretion disc, just noise,"
192 +
" as mindless as the background radiation of the cosmos itself.");
196 addText(
"The " + corona +
" exhibits fluctuations indicative of recent antimatter application.");
203 if (desc !=
null && desc.
hasText3()) {
208 case DUMP_PLANETKILLER:
209 addText(
"Your officers respond promptly to the order, and move to the task with all alacrity. There is an edge to their call-and-response,"
210 +
" however, as if they cannot help but acknowledge the deep sense of the gravity in this act.\n"
211 +
"\"Package ready to drop, captain,\" your ops chief says. \"On your order.\"");
213 options.
addOption(
"\"Destroy it!\"", OptionId.DUMP_PLANETKILLER_CONT_1,
null);
214 options.
addOption(
"\"No... I will keep it.\"", OptionId.DUMP_PLANETKILLER_ON_SECOND_THOUGHT,
null);
216 case DUMP_PLANETKILLER_ON_SECOND_THOUGHT:
219 case DUMP_PLANETKILLER_CONT_1:
220 addText(
"At your command the planetkiller, locked in its cradle, is boosted toward the very center of the black hole, up and over the plane of the accretion disc.\n\n"
221 +
"With a flash only a little more than noise in the sensor telemetry, it is gone.");
226 options.
addOption(
"Leave", OptionId.LEAVE,
null);
227 options.
setShortcut(OptionId.LEAVE, Keyboard.KEY_ESCAPE,
false,
false,
false,
true);
238 case ADD_STABLE_CONFIRM:
240 if (system !=
null) {
247 addText(
"Preparations are made, and you give the go-ahead. " +
248 "A few tense minutes later, the chief engineer reports success. " +
249 "The resulting stable location won't last for millennia, like " +
250 "naturally-occurring ones - but it'll do for your purposes.");
254 case ADD_STABLE_DESCRIBE:
255 addText(
"The procedure requires spreading prodigious amounts of antimatter " + corona2 +
", " +
256 "according to calculations far beyond the ability of anything on the right side of the " +
257 "treaty that ended the Second AI War.");
267 boolean alreadyCant =
false;
269 options.
addOption(
"Proceed with the operation", OptionId.ADD_STABLE_CONFIRM,
null);
270 }
else if (num < 2) {
271 addText(
"Normally, this procedure can only be performed in a star system without any " +
272 "stable locations. However, your chief engineer suggests an unorthodox workaround.");
273 options.
addOption(
"Proceed with the operation", OptionId.ADD_STABLE_CONFIRM,
null);
280 String reason =
"This procedure can not performed in a star system that already has " +
281 "numerous stable locations.";
282 options.
addOption(
"Proceed with the operation", OptionId.ADD_STABLE_CONFIRM,
null);
283 options.
setEnabled(OptionId.ADD_STABLE_CONFIRM,
false);
285 options.
setTooltip(OptionId.ADD_STABLE_CONFIRM, reason);
288 if (!canAfford && !alreadyCant) {
289 String reason =
"You do not have the necessary resources to carry out this procedure.";
290 options.
setEnabled(OptionId.ADD_STABLE_CONFIRM,
false);
292 options.
setTooltip(OptionId.ADD_STABLE_CONFIRM, reason);
296 options.
addOption(
"Never mind", OptionId.ADD_STABLE_NEVER_MIND,
null);
299 case ADD_STABLE_NEVER_MIND:
317 String type =
"star";
318 String corona =
"star's corona";
319 String corona2 =
"in the star's corona";
320 boolean blackHole =
false;
324 corona =
"event horizon";
325 corona2 =
"near the event horizon";
332 if (system !=
null && planet == system.
getStar() && !didAlready && !deepSpace) {
335 options.
addOption(
"Consider inducing a resonance cascade in the " + type +
"'s hyperfield, creating a stable location", OptionId.ADD_STABLE_DESCRIBE,
null);
355 if (
hasPK() && blackHole ==
true) {
356 options.
addOption(
"Dump the planetkiller weapon into the black hole", OptionId.DUMP_PLANETKILLER,
null);
359 options.
addOption(
"Leave", OptionId.LEAVE,
null);
360 options.
setShortcut(OptionId.LEAVE, Keyboard.KEY_ESCAPE,
false,
false,
false,
true);
377 private OptionId lastOptionMousedOver =
null;
386 private void addText(String text) {
390 private void appendText(String text) {
394 private String getString(String
id) {
397 String fleetOrShip =
"fleet";
399 fleetOrShip =
"ship";
401 fleetOrShip =
"fighter wing";
404 str = str.replaceAll(
"\\$fleetOrShip", fleetOrShip);
405 str = str.replaceAll(
"\\$planetName", planet.
getName());
static SettingsAPI getSettings()
static FactoryAPI getFactory()
static SectorAPI getSector()
static final String LOCAL
static final String FACTION
static final String MARKET
static final String GLOBAL
static final String PLAYER
void advance(float amount)
static int STABLE_MACHINERY_REQ
void setUnpauseOnExit(boolean unpauseOnExit)
Map< String, MemoryAPI > getMemoryMap()
void createInitialOptions()
void optionSelected(String text, Object optionData)
static int STABLE_FUEL_REQ
void optionMousedOver(String optionText, Object optionData)
void init(InteractionDialogAPI dialog)
void backFromEngagement(EngagementResultAPI result)
boolean isUnpauseOnExit()
static final String HEAVY_MACHINERY
static final String ALPHA_CORE
static final String PLANETKILLER
static String STORY_POINT_SPEND_TECHNOLOGY
static int ABYSSAL_BLACK_HOLE_UNUSUAL_READINGS
static void addFactorCreateIfNecessary(EventFactor factor, InteractionDialogAPI dialog)
void addStableLocations()
static void addCommodityLossText(String commodityId, int quantity, TextPanelAPI text)
static void addItemLossText(SpecialItemData data, int quantity, TextPanelAPI text)
boolean execute(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
static final String OPTION_ID
static boolean set(String ruleId, InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap, String params)
static int getNumStableLocations(StarSystemAPI system)
Description getDescription(String id, Type type)
String getString(String category, String id)
boolean getBoolean(String key)
Color getColor(String id)
FleetDataAPI getFleetData()
void removeFuel(float quantity)
List< FleetMemberAPI > getMembersListCopy()
TextPanelAPI getTextPanel()
VisualPanelAPI getVisualPanel()
SectorEntityToken getInteractionTarget()
void addOptionSelectedText(Object optionId)
void setOptionOnEscape(String text, Object optionId)
OptionPanelAPI getOptionPanel()
String getNameWithLowercaseType()
void setTooltip(Object data, String tooltipText)
void addOption(String text, Object data)
void setEnabled(Object data, boolean enabled)
void setShortcut(Object data, int code, boolean ctrl, boolean alt, boolean shift, boolean putLast)
CampaignFleetAPI getPlayerFleet()
void setPaused(boolean paused)
MutableCharacterStatsAPI getPlayerStats()
CharacterDataAPI getCharacterData()
StarSystemAPI getStarSystem()
String getCustomDescriptionId()
MemoryAPI getMemoryWithoutUpdate()
InteractionDialogImageVisual getCustomInteractionDialogImageVisual()
ResourceCostPanelAPI addCostPanel(String title, float height, Color color, Color dark)
LabelAPI addParagraph(String text)
void appendToLastParagraph(String text)
void showPlanetInfo(SectorEntityToken planet)
void setVisualFade(float in, float out)
void showImageVisual(InteractionDialogImageVisual visual)
void set(String key, Object value)
boolean getBoolean(String key)
void addStoryPoints(int storyPoints)