Starsector API
Loading...
Searching...
No Matches
SwordOfEventide.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions;
2
3import java.awt.Color;
4import java.util.List;
5import java.util.Map;
6
7import com.fs.starfarer.api.EveryFrameScript;
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.InteractionDialogAPI;
10import com.fs.starfarer.api.campaign.TextPanelAPI;
11import com.fs.starfarer.api.campaign.econ.MarketAPI;
12import com.fs.starfarer.api.campaign.rules.MemoryAPI;
13import com.fs.starfarer.api.characters.PersonAPI;
14import com.fs.starfarer.api.impl.campaign.eventide.DuelDialogDelegate;
15import com.fs.starfarer.api.impl.campaign.eventide.DuelPanel;
16import com.fs.starfarer.api.impl.campaign.ids.People;
17import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
18import com.fs.starfarer.api.ui.TooltipMakerAPI;
19import com.fs.starfarer.api.util.Misc;
20import com.fs.starfarer.api.util.Misc.Token;
21
22public class SwordOfEventide extends HubMissionWithSearch {
23
24// public void init(CustomPanelAPI panel, DialogCallbacks callbacks) {
25// this.callbacks = callbacks;
26// callbacks.getPanelFader().setDurationOut(2f);
27// duelPanel.init(panel, callbacks, dialog);
28// if (musicId != null && !musicId.isEmpty()) {
29// Global.getSoundPlayer().setSuspendDefaultMusicPlayback(true);
30// Global.getSoundPlayer().playCustomMusic(1, 1, musicId);
31// } else {
32// Global.getSoundPlayer().pauseMusic();
33// Global.getSoundPlayer().setSuspendDefaultMusicPlayback(true);
34// }
35// }
36// public void reportDismissed(int option) {
37// Global.getSoundPlayer().setSuspendDefaultMusicPlayback(false);
38// Global.getSoundPlayer().restartCurrentMusic();
39
40 public static String SOE_MUSIC_STATE = "$soe_musicState";
41 public static String SOE_STATE_PARTY = "party";
42 public static String SOE_STATE_PRE_DUEL = "pre_duel";
43 public static String SOE_STATE_DUEL = "duel";
44 public static String SOE_STATE_POST_DUEL = "post_duel";
45
46 public static String PARTY_CHATTER = "soe_party_chatter";
47 public static String PARTY_MUSIC = "music_soe_party";
48 public static String DUEL_MUSIC = "music_soe_fight";
49
50 public static class SOEMusicPlayer implements EveryFrameScript {
51 public boolean done = false;
52 public String currState = null;
53
54 public SOEMusicPlayer() {
55 }
56 public void advance(float amount) {
57 String state = Global.getSector().getMemoryWithoutUpdate().getString(SOE_MUSIC_STATE);
58 if (state != null && !state.equals(currState)) {
59 if (SOE_STATE_PARTY.equals(state)) {
62 } else if (SOE_STATE_PRE_DUEL.equals(state)) {
65 } else if (SOE_STATE_DUEL.equals(state)) {
68 } else if (SOE_STATE_POST_DUEL.equals(state)) {
71 }
72 currState = state;
73 }
74
75 if (SOE_STATE_PARTY.equals(state)) {
77 } else if (SOE_STATE_PRE_DUEL.equals(state)) {
79 }
80
81 if (!Global.getSector().isPaused()) {
82 stop();
83 }
84 }
85 public boolean isDone() {
86 return done;
87 }
88 public boolean runWhilePaused() {
89 return true;
90 }
91 public void stop() {
92 done = true;
95 }
96 }
97
98
99 public static enum Stage {
100 GO_TO_EVENTIDE,
101 COMPLETED,
102 }
103
104 protected PersonAPI neriene_rao; // neriene rao
105 protected PersonAPI caspian_sang; // caspian sang
106 protected PersonAPI orcus_rao; // orcus rao
107
108 protected MarketAPI eventide;
109 //protected MarketAPI chicomoztoc;
110
111 public static float MISSION_DAYS = 120f;
112
113 @Override
114 protected boolean create(MarketAPI createdAt, boolean barEvent) {
115 // if already accepted by the player, abort
116 if (!setGlobalReference("$soe_ref","$soe_inProgress")) {
117 return false;
118 }
119
120 neriene_rao = getImportantPerson(People.NERIENE_RAO);
121 if (neriene_rao == null) return false;
122 caspian_sang = getImportantPerson(People.CASPIAN);
123 if (caspian_sang == null) return false;
124 orcus_rao = getImportantPerson(People.RAO);
125 if (orcus_rao == null) return false;
126
127 eventide = Global.getSector().getEconomy().getMarket("eventide");
128 if (eventide == null) return false;
129
130 setStartingStage(Stage.GO_TO_EVENTIDE);
131 addSuccessStages(Stage.COMPLETED);
132
133 setStoryMission();
134
135 makeImportant(eventide, "$soe_invitedToBall", Stage.GO_TO_EVENTIDE);
136 //setStageOnMemoryFlag(Stage.COMPLETED, baird.getMarket(), "$gaTTB_completed");
137
138 setStageOnGlobalFlag(Stage.COMPLETED, "$soe_completed");
139
140 setRepFactionChangesNone();
141 setRepPersonChangesNone();
142
143 beginStageTrigger(Stage.GO_TO_EVENTIDE);
144 triggerSetGlobalMemoryValuePermanent("$didEventideRaoBall", true);
145 endTrigger();
146
147 return true;
148 }
149
150 protected void updateInteractionDataImpl() {
151
152 }
153
154 protected SOEMusicPlayer player = null;
155 @Override
156 protected boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog,
157 List<Token> params, final Map<String, MemoryAPI> memoryMap) {
158 if ("THEDUEL".equals(action)) {
159 TextPanelAPI text = dialog.getTextPanel();
160// text.setFontOrbitronUnnecessarilyLarge();
161// Color color = Misc.getBasePlayerColor();
162// color = Global.getSector().getFaction(Factions.HEGEMONY).getBaseUIColor();
163// text.addPara("THE DUEL", color);
164// text.setFontInsignia();
165 text.addImage("misc", "THEDUEL");
166 return true;
167 } else if ("addMusicPlayer".equals(action)) {
168 if (!Global.getSector().hasTransientScript(SOEMusicPlayer.class)) {
169 player = new SOEMusicPlayer();
170 Global.getSector().addTransientScript(player);
171 Global.getSector().getMemoryWithoutUpdate().set(SOE_MUSIC_STATE, SOE_STATE_PARTY);
172 }
173 return true;
174 } else if ("cleanUpMusicPlayer".equals(action)) {
175 if (player != null) {
176 player.stop();;
177 }
178 return true;
179 } else if ("crowdGasp".equals(action)) {
180 Global.getSoundPlayer().playUISound("soe_crowd_gasp", 1f, 1f);
181 Global.getSector().getMemoryWithoutUpdate().set(SOE_MUSIC_STATE, SOE_STATE_PRE_DUEL);
182 return true;
183 } else if ("postDuel".equals(action)) {
184 Global.getSector().getMemoryWithoutUpdate().set(SOE_MUSIC_STATE, SOE_STATE_POST_DUEL);
185 return true;
186 } else if ("beginDuel".equals(action)) {
187 Global.getSector().getMemoryWithoutUpdate().set(SOE_MUSIC_STATE, SOE_STATE_DUEL);
188
189 boolean playerSkilled = false;
190 if (params.size() >= 2) {
191 playerSkilled = params.get(1).getBoolean(memoryMap);
192 }
193 final DuelPanel duelPanel = DuelPanel.createDefault(playerSkilled, true, "soe_ambience");
194 dialog.showCustomVisualDialog(1024, 700, new DuelDialogDelegate(null, duelPanel, dialog, memoryMap, false));
195 return true;
196 } else if ("beginTutorial".equals(action)) {
197 boolean playerSkilled = false;
198 if (params.size() >= 2) {
199 playerSkilled = params.get(1).getBoolean(memoryMap);
200 }
201 final DuelPanel duelPanel = DuelPanel.createTutorial(playerSkilled, "soe_ambience");
202 dialog.showCustomVisualDialog(1024, 700, new DuelDialogDelegate(null, duelPanel, dialog, memoryMap, true));
203 return true;
204 }
205 return super.callAction(action, ruleId, dialog, params, memoryMap);
206 }
207
208 @Override
209 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
210 float opad = 10f;
211 Color h = Misc.getHighlightColor();
212 if (currentStage == Stage.GO_TO_EVENTIDE) {
213 info.addPara("Go to Eventide in the Samarra system.", opad);
214 }
215 }
216
217 @Override
218 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
219 Color h = Misc.getHighlightColor();
220 if (currentStage == Stage.GO_TO_EVENTIDE) {
221 info.addPara("Go to Eventide in the Samarra system", tc, pad);
222 return true;
223 }
224 return false;
225 }
226
227 @Override
228 public String getBaseName() {
229 return "Princess of Persea";
230 }
231
232 @Override
233 public String getPostfixForState() {
234 if (startingStage != null) {
235 return "";
236 }
237 return super.getPostfixForState();
238 }
239}
240
241
242
243
244
static SoundPlayerAPI getSoundPlayer()
Definition Global.java:43
static SectorAPI getSector()
Definition Global.java:59
boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog, List< Token > params, final Map< String, MemoryAPI > memoryMap)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
boolean create(MarketAPI createdAt, boolean barEvent)
void setSuspendDefaultMusicPlayback(boolean suspendMusicPlayback)
void playCustomMusic(int fadeOutIfAny, int fadeIn, String musicSetId)
void playUILoop(String id, float pitch, float volume)
SoundAPI playUISound(String id, float pitch, float volume)