96 public void init(InteractionDialogAPI dialog) {
98 textPanel = dialog.getTextPanel();
99 options = dialog.getOptionPanel();
100 visual = dialog.getVisualPanel();
103 jumpPoint = (JumpPointAPI) (dialog.getInteractionTarget());
105 fuelCost = playerFleet.getLogistics().getFuelCostPerLightYear();
106 float rounded = Math.round(
fuelCost);
107 if (
fuelCost > 0 && rounded <= 0) rounded = 1;
112 }
else if (jumpPoint.isInHyperspace()) {
118 visual.setVisualFade(0.25f, 0.25f);
119 if (jumpPoint.getCustomInteractionDialogImageVisual() !=
null) {
120 visual.showImageVisual(jumpPoint.getCustomInteractionDialogImageVisual());
123 visual.showImagePortion(
"illustrations",
"jump_point_wormhole", 640, 400, 0, 0, 480, 300);
125 if (playerFleet.getContainingLocation().isHyperspace()) {
126 visual.showImagePortion(
"illustrations",
"jump_point_hyper", 640, 400, 0, 0, 480, 300);
128 visual.showImagePortion(
"illustrations",
"jump_point_normal", 640, 400, 0, 0, 480, 300);
136 dialog.setOptionOnEscape(
"Leave", OptionId.LEAVE);
151 if (optionData ==
null)
return;
153 if (DumpMemory.OPTION_ID == optionData) {
154 Map<String, MemoryAPI> memoryMap =
new HashMap<String, MemoryAPI>();
155 MemoryAPI memory = dialog.getInteractionTarget().getMemory();
157 memoryMap.put(MemKeys.LOCAL, memory);
158 if (dialog.getInteractionTarget().getFaction() !=
null) {
159 memoryMap.put(MemKeys.FACTION, dialog.getInteractionTarget().getFaction().getMemory());
164 memoryMap.put(MemKeys.PLAYER,
Global.
getSector().getCharacterData().getMemory());
166 if (dialog.getInteractionTarget().getMarket() !=
null) {
167 memoryMap.put(MemKeys.MARKET, dialog.getInteractionTarget().getMarket().getMemory());
169 new DumpMemory().execute(
null, dialog,
null, memoryMap);
176 OptionId option = (OptionId) optionData;
180 dialog.addOptionSelectedText(option);
184 boolean unstable = jumpPoint.getMemoryWithoutUpdate().getBoolean(
UNSTABLE_KEY);
185 boolean stabilizing = jumpPoint.getMemoryWithoutUpdate().getExpire(
UNSTABLE_KEY) > 0;
186 boolean canStabilize = jumpPoint.getMemoryWithoutUpdate().getBoolean(
CAN_STABILIZE);
187 boolean canTransverseJump =
Global.
getSector().getPlayerFleet().hasAbility(Abilities.TRANSVERSE_JUMP);
188 boolean tutorialInProgress = TutorialMissionIntel.isTutorialInProgress();
221 addText(
"Your fleet approaches the wormhole.");
223 addText(getString(
"approach"));
227 if (desc !=
null && desc.hasText3()) {
228 addText(desc.getText3());
231 String noun =
"jump-point";
236 float dur = jumpPoint.getMemoryWithoutUpdate().getExpire(
UNSTABLE_KEY);
239 String durStr =
"" + (int) dur;
240 String days =
"days";
249 textPanel.addPara(
"This wormhole is stabilizing and will become usable "
250 +
"within %s " + days +
".", Misc.getHighlightColor(), durStr);
252 String time = Misc.getStringForDays((
int) dur);
254 if (time.contains(
"many")) {
255 label = textPanel.addParagraph(
256 "This wormhole is gradually stabilizing, but will not be usable for " + time +
".");
258 label = textPanel.addParagraph(
259 "This wormhole is stabilizing, and should be usable within " + time +
".");
262 label.setHighlightColor(HIGHLIGHT_COLOR);
263 label.setHighlight(time);
267 if (stabilizing && !canTransverseJump) {
268 if (tutorialInProgress) {
269 addText(
"This jump-point is stabilizing and should be usable within a day at the most.");
271 addText(
"This jump-point is stabilizing but will not be usable for some time.");
274 addText(
"This jump-point is unstable and can not be used.");
277 if (canTransverseJump && !tutorialInProgress ) {
278 addText(
"Until it restabilizes, hyperspace is only accessible via Transverse Jump.");
282 if (!jumpPoint.isInHyperspace()) {
284 if (!jumpPoint.getDestinations().isEmpty()) {
286 addText(
"The nav computer pings the wormhole terminus, establishing a data connection through drive-field fluctuations. "
287 +
"In under a minute, and only a moment of unease as the agrav self-correction settles, the process is complete. "
288 +
"Your primary interface unveils a list of possible destinations.");
291 textPanel.addParagraph(
"Activating this " + noun +
" to let your fleet pass through will cost " + (
int)
fuelCost +
" fuel.");
292 textPanel.highlightInLastPara(Misc.getHighlightColor(),
"" + (
int)
fuelCost);
294 int fuel = (int) playerFleet.getCargo().getFuel();
296 textPanel.addParagraph(
"Activating this " + noun +
" to let your fleet pass through will cost " + (
int)
fuelCost +
" fuel. You have no fuel.");
298 textPanel.addParagraph(
"Activating this " + noun +
" to let your fleet pass through will cost " + (
int)
fuelCost +
" fuel. You only have " + fuel +
" fuel.");
300 textPanel.highlightInLastPara(Misc.getNegativeHighlightColor(),
"" + (int)
fuelCost,
"" + fuel);
308 createInitialOptions();
313 jumpPoint.getMemoryWithoutUpdate().expire(
UNSTABLE_KEY, 1f);
315 addText(
"You load the stabilization algorithm into your jump program and the drive field goes through a series " +
316 "of esoteric fluctuations, their resonance gradually cancelling out the instability in this jump-point.");
318 addText(
"The jump-point should be stable enough to use within a day or so.");
320 createInitialOptions();
322 case JUMP_CONFIRM_TURN_TRANSPONDER_ON:
323 AbilityPlugin t =
Global.
getSector().getPlayerFleet().getAbility(Abilities.TRANSPONDER);
324 if (t !=
null && !t.isActive()) {
332 case RETRIEVE_ANCHOR_CONFIRM:
333 dialog.getTextPanel().addPara(
334 "You give the order. Before long, your ops chief confirms that the wormhole anchor has been stowed in a secure hold on your flagship.");
335 WormholeManager.get().removeWormhole(jumpPoint, dialog);
336 options.clearOptions();
337 options.addOption(
"Leave", OptionId.LEAVE,
null);
338 options.setShortcut(OptionId.LEAVE, Keyboard.KEY_ESCAPE,
false,
false,
false,
true);
340 case RETRIEVE_ANCHOR:
341 dialog.getTextPanel().addPara(
342 "This will shut down the wormhole and free up the stable point for other uses.");
343 options.clearOptions();
344 options.addOption(
"Confirm your orders", OptionId.RETRIEVE_ANCHOR_CONFIRM,
null);
346 options.addOption(
"Abort the operation", OptionId.LEAVE,
null);
347 options.setShortcut(OptionId.LEAVE, Keyboard.KEY_ESCAPE,
false,
false,
false,
true);
356 if (jumpOptions.contains(option)) {
357 JumpDestination dest = destinationMap.get(option);
361 SectorEntityToken target = dest.getDestination();
363 if (target !=
null && target.getContainingLocation() !=
null &&
364 !target.getContainingLocation().isHyperspace() && !player.isTransponderOn()) {
365 List<FactionAPI> wouldBecomeHostile = TransponderAbility.getFactionsThatWouldBecomeHostile(player);
366 boolean wouldMindTOff =
false;
367 boolean isPopulated =
false;
368 for (MarketAPI market :
Global.
getSector().getEconomy().getMarkets(target.getContainingLocation())) {
369 if (market.isHidden())
continue;
370 if (market.getFaction().isPlayerFaction())
continue;
373 if (!market.getFaction().isHostileTo(Factions.PLAYER) &&
374 !market.isFreePort() &&
375 !market.getFaction().getCustomBoolean(Factions.CUSTOM_ALLOWS_TRANSPONDER_OFF_TRADE)) {
376 wouldMindTOff =
true;
382 textPanel.addPara(
"Your transponder is off, and patrols " +
384 target.getContainingLocation().getNameWithLowercaseType() +
385 " are likely to give you trouble over the fact, if you're spotted.");
387 textPanel.addPara(
"Your transponder is off, but any patrols in the " +
388 target.getContainingLocation().getNameWithLowercaseType() +
389 " are unlikely to raise the issue.");
392 if (!wouldBecomeHostile.isEmpty()) {
393 String str =
"Turning the transponder on now would reveal your hostile actions to";
394 boolean first =
true;
395 boolean last =
false;
396 for (FactionAPI faction : wouldBecomeHostile) {
397 last = wouldBecomeHostile.indexOf(faction) == wouldBecomeHostile.size() - 1;
398 if (first || !last) {
399 str +=
" " + faction.getDisplayNameWithArticle() +
",";
401 str +=
" and " + faction.getDisplayNameWithArticle() +
",";
404 str = str.substring(0, str.length() - 1) +
".";
405 textPanel.addPara(str, Misc.getNegativeHighlightColor());
408 options.clearOptions();
410 options.addOption(
"Turn the transponder on and then jump", OptionId.JUMP_CONFIRM_TURN_TRANSPONDER_ON,
null);
411 options.addOption(
"Jump, keeping the transponder off", OptionId.JUMP_CONFIRM,
null);
414 options.addOption(
"Abort the jump", OptionId.LEAVE,
null);
415 options.setShortcut(OptionId.LEAVE, Keyboard.KEY_ESCAPE,
false,
false,
false,
true);
439 if (
Global.
getSector().getUIData().getCourseTarget() == dialog.getInteractionTarget()) {
446 Global.
getSector().doHyperspaceTransition(playerFleet, jumpPoint, dest);
448 playerFleet.getCargo().removeFuel(
fuelCost);
458 if (jumpPoint.getDestinations().isEmpty())
return;
459 JumpDestination dest = jumpPoint.getDestinations().get(0);
460 SectorEntityToken target = dest.getDestination();
461 if (target ==
null || target.getContainingLocation() ==
null)
return;
463 List<CampaignFleetAPI> fleets =
new ArrayList<CampaignFleetAPI>();
464 boolean hostile =
false;
465 float minDist = Float.MAX_VALUE;
467 for (CampaignFleetAPI other : target.getContainingLocation().getFleets()) {
468 float dist = Misc.getDistance(target, other);
471 if (other.getAI() !=
null) {
472 hostile |= other.getAI().isHostileTo(
Global.
getSector().getPlayerFleet());
474 hostile |= other.getFaction().isHostileTo(Factions.PLAYER);
476 if (other.getMemoryWithoutUpdate().getBoolean(MemFlags.MEMORY_KEY_PIRATE)) {
480 maxDanger = Math.max(maxDanger, Misc.getDangerLevel(other));
482 if (dist < minDist) minDist = dist;
485 TextPanelAPI text = dialog.getTextPanel();
487 if (maxDanger >= 2) {
488 String noun =
"jump-point";
490 text.addPara(
"Warning!", Misc.getNegativeHighlightColor());
493 String where =
"a short distance away from the exit";
496 where =
"extremely close to the exit";
499 text.addPara(
"The jump-point exhibits fluctuations " +
500 "characteristic of drive field activity " + where +
".",
501 Misc.getNegativeHighlightColor(), whereHL);
503 text.addPara(
"A disposable probe sends back a microburst of information: forces " +
504 "near the exit are assesed likely hostile and a possible threat to your fleet.",
505 Misc.getNegativeHighlightColor(),
"hostile",
"threat");