Starsector API
Loading...
Searching...
No Matches
EndConversation.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.rulecmd;
2
3import java.util.List;
4import java.util.Map;
5
6import com.fs.starfarer.api.campaign.InteractionDialogAPI;
7import com.fs.starfarer.api.campaign.RuleBasedDialog;
8import com.fs.starfarer.api.campaign.rules.MemKeys;
9import com.fs.starfarer.api.campaign.rules.MemoryAPI;
10import com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl;
11import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
12import com.fs.starfarer.api.util.Misc;
13import com.fs.starfarer.api.util.Misc.Token;
14
15public class EndConversation extends BaseCommandPlugin {
16
17 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
18 FleetInteractionDialogPluginImpl.inConversation = false;
19
20 boolean doNotFire = false;
21 boolean withContinue = true;
22 if (params.size() > 0) {
23 String str = params.get(0).getString(memoryMap);
24 if (str != null && str.equals("DO_NOT_FIRE")) {
25 doNotFire = true;
26 }
27 if (str != null && str.equals("NO_CONTINUE")) {
28 withContinue = false;
29 }
30 }
31
32 MemoryAPI memory = memoryMap.get(MemKeys.LOCAL);
33 if (memory != null && memory.getBoolean("$doNotFireOnConvEnd")) {
34 doNotFire = true;
35 }
36
37 if (!withContinue) {
38 new ShowDefaultVisual().execute(null, dialog, Misc.tokenize(""), memoryMap);
39 }
40
41 if (dialog.getPlugin() instanceof RuleBasedDialog) {
42 dialog.getInteractionTarget().setActivePerson(null);
43 ((RuleBasedDialog) dialog.getPlugin()).notifyActivePersonChanged();
44
45 if (!doNotFire) {
46 if (dialog.getPlugin() instanceof FleetInteractionDialogPluginImpl) {
47 //((FleetInteractionDialogPluginImpl)dialog.getPlugin()).optionSelected(null, OptionId.INIT);
48 ((RuleBasedDialog) dialog.getPlugin()).reinit(withContinue);
49 } else {
50 MemoryAPI local = memoryMap.get(MemKeys.LOCAL);
51 MemoryAPI marketMem = memoryMap.get(MemKeys.MARKET);
52 boolean custom = marketMem != null && marketMem.getBoolean(MemFlags.MARKET_HAS_CUSTOM_INTERACTION_OPTIONS);
53 if (!custom && local != null && local.getBoolean("$hasMarket") && !local.contains("$menuState")) {
54 FireBest.fire(null, dialog, memoryMap, "MarketPostOpen");
55 } else {
56 FireAll.fire(null, dialog, memoryMap, "PopulateOptions");
57 }
58 }
59 }
60 }
61 return true;
62 }
63
64}
boolean execute(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
static boolean fire(String ruleId, InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap, String params)
Definition FireAll.java:55
static boolean fire(String ruleId, InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap, String params)
Definition FireBest.java:56
boolean execute(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)