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
19public class SharedData {
20
21 public static class UniqueEncounterData {
22 public List<String> interactedWith = new ArrayList<String>();
23 public List<String> historianBlurbsShown = new ArrayList<String>();
24
25 public boolean wasInteractedWith(String id) {
26 return interactedWith.contains(id);
27 }
28
29 public void setWasInteractedWith(String id) {
30 interactedWith.add(id);
31 }
32
33 protected Object readResolve() {
34 if (historianBlurbsShown == null) {
35 historianBlurbsShown = new ArrayList<String>();
36 }
37 return this;
38 }
39
40 }
41
42 protected TimeoutTracker<String> marketsThatSentRelief = new TimeoutTracker<String>();
43 protected TimeoutTracker<String> marketsThatSentTradeFleet = new TimeoutTracker<String>();
44 //private TimeoutTracker<String> starSystemCustomsTimeout = new TimeoutTracker<String>();
45
46 // faction, then star system
47 protected Map<String, TimeoutTracker<String>> starSystemCustomsTimeout = new LinkedHashMap<String, TimeoutTracker<String>>();
48
49 //protected SectorActivityTracker activityTracker = new SectorActivityTracker();
51
52 protected Set<String> marketsWithoutTradeFleetSpawn = new HashSet<String>();
53 //protected Set<String> marketsWithoutPatrolSpawn = new HashSet<String>();
54
55 private PersonBountyEventData personBountyEventData = new PersonBountyEventData();
56
57 protected float playerPreLosingBattleFP = -1;
58 protected float playerPreLosingBattleCrew = -1;
59 protected long playerLosingBattleTimestamp = 0;
60
61 protected MonthlyReport previousReport = new MonthlyReport();
62 protected MonthlyReport currentReport = new MonthlyReport();
63
64 protected UniqueEncounterData uniqueEncounterData = new UniqueEncounterData();
65
66 public SharedData() {
67 }
68
69 public MonthlyReport getPreviousReport() {
70 if (previousReport == null) previousReport = new MonthlyReport();
71 return previousReport;
72 }
73 public MonthlyReport getCurrentReport() {
74 if (currentReport == null) currentReport = new MonthlyReport();
75 return currentReport;
76 }
77 public void setCurrentReport(MonthlyReport currentReport) {
78 this.currentReport = currentReport;
79 }
80 public void setPreviousReport(MonthlyReport previousReport) {
81 this.previousReport = previousReport;
82 }
83
84 public void rollOverReport() {
86 currentReport = new MonthlyReport();
87 }
88
92
94 this.playerLosingBattleTimestamp = playerLosingBattleTimestamp;
95 }
96
99 }
100
102 this.playerPreLosingBattleFP = playerPreLosingBattleFP;
103 }
104
107 }
108
110 this.playerPreLosingBattleCrew = playerPreLosingBattleCrew;
111 }
112
113 public UniqueEncounterData getUniqueEncounterData() {
114 return uniqueEncounterData;
115 }
116
117 protected Object readResolve() {
118 if (starSystemCustomsTimeout == null) {
119 starSystemCustomsTimeout = new LinkedHashMap<String, TimeoutTracker<String>>();
120 }
121 if (personBountyEventData == null) {
122 personBountyEventData = new PersonBountyEventData();
123 }
124 if (uniqueEncounterData == null) {
125 uniqueEncounterData = new UniqueEncounterData();
126 }
127 return this;
128 }
129
131 return personBountyEventData;
132 }
133
134 public void advance(float amount) {
135
136 SectorAPI sector = Global.getSector();
137 if (sector.isPaused()) {
138 return;
139 }
140
141 float days = sector.getClock().convertToDays(amount);
142
143 marketsThatSentRelief.advance(days);
144 marketsThatSentTradeFleet.advance(days);
145
146 for (TimeoutTracker<String> curr : starSystemCustomsTimeout.values()) {
147 curr.advance(days);
148 }
149
150 //activityTracker.advance(days);
152 }
153
154
155
156// public SectorActivityTracker getActivityTracker() {
157// return activityTracker;
158// }
159
160 public TimeoutTracker<String> getMarketsThatSentRelief() {
162 }
163 public TimeoutTracker<String> getMarketsThatSentTradeFleet() {
165 }
166
170
171 public static SharedData getData() {
172 Object data = Global.getSector().getPersistentData().get(CoreScript.SHARED_DATA_KEY);
173 if (data == null) {
174 data = new SharedData();
175 Global.getSector().getPersistentData().put(CoreScript.SHARED_DATA_KEY, data);
176 }
177 return (SharedData) data;
178 }
179
180 public Set<String> getMarketsWithoutTradeFleetSpawn() {
182 }
183
184
185 public void resetCustomsTimeouts() {
187 }
188
189 public TimeoutTracker<String> getStarSystemCustomsTimeout(String factionId) {
190 TimeoutTracker<String> tracker = starSystemCustomsTimeout.get(factionId);
191 if (tracker == null) {
192 tracker = new TimeoutTracker<String>();
193 starSystemCustomsTimeout.put(factionId, tracker);
194 }
195 return tracker;
196 }
197
198}
199
200
201
202
static SectorAPI getSector()
Definition Global.java:59
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