Starsector API
Loading...
Searching...
No Matches
SharedData.java
Go to the documentation of this file.
1
4package com.fs.starfarer.api.impl.campaign.shared;
5
6import java.util.ArrayList;
7import java.util.HashSet;
8import java.util.LinkedHashMap;
9import java.util.List;
10import java.util.Map;
11import java.util.Set;
12
13import com.fs.starfarer.api.Global;
14import com.fs.starfarer.api.campaign.SectorAPI;
15import com.fs.starfarer.api.campaign.econ.MonthlyReport;
16import com.fs.starfarer.api.impl.campaign.CoreScript;
17import com.fs.starfarer.api.util.TimeoutTracker;
18
24public class SharedData {
25
26 public static class UniqueEncounterData {
27 public List<String> interactedWith = new ArrayList<String>();
28 public List<String> historianBlurbsShown = new ArrayList<String>();
29
30 public boolean wasInteractedWith(String id) {
31 return interactedWith.contains(id);
32 }
33
34 public void setWasInteractedWith(String id) {
35 interactedWith.add(id);
36 }
37
38 protected Object readResolve() {
39 if (historianBlurbsShown == null) {
40 historianBlurbsShown = new ArrayList<String>();
41 }
42 return this;
43 }
44
45 }
46
49 //private TimeoutTracker<String> starSystemCustomsTimeout = new TimeoutTracker<String>();
50
51 // faction, then star system
52 protected Map<String, TimeoutTracker<String>> starSystemCustomsTimeout = new LinkedHashMap<String, TimeoutTracker<String>>();
53
54 //protected SectorActivityTracker activityTracker = new SectorActivityTracker();
56
57 protected Set<String> marketsWithoutTradeFleetSpawn = new HashSet<String>();
58 //protected Set<String> marketsWithoutPatrolSpawn = new HashSet<String>();
59
60 private PersonBountyEventData personBountyEventData = new PersonBountyEventData();
61
62 protected float playerPreLosingBattleFP = -1;
63 protected float playerPreLosingBattleCrew = -1;
64 protected long playerLosingBattleTimestamp = 0;
65
68
69 protected UniqueEncounterData uniqueEncounterData = new UniqueEncounterData();
70
71 public SharedData() {
72 }
73
75 if (previousReport == null) previousReport = new MonthlyReport();
76 return previousReport;
77 }
79 if (currentReport == null) currentReport = new MonthlyReport();
80 return currentReport;
81 }
83 this.currentReport = currentReport;
84 }
86 this.previousReport = previousReport;
87 }
88
93
97
99 this.playerLosingBattleTimestamp = playerLosingBattleTimestamp;
100 }
101
104 }
105
107 this.playerPreLosingBattleFP = playerPreLosingBattleFP;
108 }
109
112 }
113
115 this.playerPreLosingBattleCrew = playerPreLosingBattleCrew;
116 }
117
118 public UniqueEncounterData getUniqueEncounterData() {
119 return uniqueEncounterData;
120 }
121
122 protected Object readResolve() {
123 if (starSystemCustomsTimeout == null) {
124 starSystemCustomsTimeout = new LinkedHashMap<String, TimeoutTracker<String>>();
125 }
126 if (personBountyEventData == null) {
127 personBountyEventData = new PersonBountyEventData();
128 }
129 if (uniqueEncounterData == null) {
130 uniqueEncounterData = new UniqueEncounterData();
131 }
132 return this;
133 }
134
136 return personBountyEventData;
137 }
138
139 public void advance(float amount) {
140
141 SectorAPI sector = Global.getSector();
142 if (sector.isPaused()) {
143 return;
144 }
145
146 float days = sector.getClock().convertToDays(amount);
147
148 marketsThatSentRelief.advance(days);
149 marketsThatSentTradeFleet.advance(days);
150
152 curr.advance(days);
153 }
154
155 //activityTracker.advance(days);
157 }
158
159
160
161// public SectorActivityTracker getActivityTracker() {
162// return activityTracker;
163// }
164
171
175
176 public static SharedData getData() {
178 if (data == null) {
179 data = new SharedData();
181 }
182 return (SharedData) data;
183 }
184
185 public Set<String> getMarketsWithoutTradeFleetSpawn() {
187 }
188
189
190 public void resetCustomsTimeouts() {
192 }
193
195 TimeoutTracker<String> tracker = starSystemCustomsTimeout.get(factionId);
196 if (tracker == null) {
197 tracker = new TimeoutTracker<String>();
198 starSystemCustomsTimeout.put(factionId, tracker);
199 }
200 return tracker;
201 }
202
203}
204
205
206
207
static SectorAPI getSector()
Definition Global.java:65
TimeoutTracker< String > getStarSystemCustomsTimeout(String factionId)
void setCurrentReport(MonthlyReport currentReport)
void setPlayerLosingBattleTimestamp(long playerLosingBattleTimestamp)
void setPlayerPreLosingBattleFP(float playerPreLosingBattleFP)
void setPreviousReport(MonthlyReport previousReport)
void setPlayerPreLosingBattleCrew(float playerPreLosingBattleCrew)
Map< String, TimeoutTracker< String > > starSystemCustomsTimeout
Map< String, Object > getPersistentData()