Starsector API
Loading...
Searching...
No Matches
BaseHubMissionCreator.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions.hub;
2
3import java.util.Random;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.RepLevel;
7import com.fs.starfarer.api.impl.campaign.ids.Tags;
8import com.fs.starfarer.api.loading.PersonMissionSpec;
9
11
12 protected int numCompleted = 0;
13 protected int numFailed = 0;
14 protected long seed;
15 protected transient Random genRandom = null;
16
17 //protected Float requiredRep = null;
18
19 protected transient PersonMissionSpec spec = null;
20 protected String specId = null;
21
22 protected boolean wasAutoAdded = false;
23 protected boolean isActive = true;
24
25 public BaseHubMissionCreator(PersonMissionSpec spec) {
26 this.spec = spec;
27 if (spec != null) {
28 specId = spec.getMissionId();
29 }
30 }
31
32 protected Object readResolve() {
34 return this;
35 }
36
37 public PersonMissionSpec getSpec() {
38 return spec;
39 }
40
41 public String getSpecId() {
42 return specId;
43 }
44
46 return spec.createMission();
47 }
48
49// public void updateSeed() {
50// seed = Misc.genRandomSeed();
51// }
52 public void setSeed(long seed) {
53 this.seed = seed;
54 }
55
56 public void updateRandom() {
57 genRandom = new Random(seed);
58 }
59
60 public void incrCompleted() {
62 }
63
64 public int getNumCompleted() {
65 return numCompleted;
66 }
67
68 public void setNumCompleted(int numCompleted) {
69 this.numCompleted = numCompleted;
70 }
71
72 public void incrFailed() {
73 numFailed++;
74 }
75
76 public int getNumFailed() {
77 return numFailed;
78 }
79
80 public void setNumFailed(int numFailed) {
81 this.numFailed = numFailed;
82 }
83
84
85 public float getFrequencyWeight() {
86 return spec.getFreq();
87 }
88
90 return 0f;
91 }
92
94 return spec.getMinTimeout() + (float) Math.random() * (spec.getMaxTimeout() - spec.getMinTimeout());
95 }
96
98 return spec.getMinTimeout() + (float) Math.random() * (spec.getMaxTimeout() - spec.getMinTimeout());
99 }
100
102 return spec.getMinTimeout() + (float) Math.random() * (spec.getMaxTimeout() - spec.getMinTimeout());
103 }
104
105// public float getAcceptedTimeoutDuration() {
106// return 0f;
107// }
108//
109// public float getCompletedTimeoutDuration() {
110// return 30f + (float) Math.random() * 30f;
111// }
112//
113// public float getFailedTimeoutDuration() {
114// return 30f + (float) Math.random() * 30f;
115// }
116
117 public boolean isPriority() {
118 return spec.hasTag(Tags.MISSION_PRIORITY);
119 }
120
121 public boolean matchesRep(float rep) {
122 RepLevel level = RepLevel.getLevelFor(rep);
123 if (spec.getMinRep() != null) {
124 if (!level.isAtWorst(spec.getMinRep())) return false;
125 }
126 if (spec.getMaxRep() != null) {
127 if (!level.isAtBest(spec.getMaxRep())) return false;
128 }
129 return true;
130 }
131
132// public float getRequiredRep() {
133// //return 0f;
134// if (requiredRep != null) return requiredRep;
135// return -RepLevel.INHOSPITABLE.getMax() + 0.01f;
136// }
137
138 public Random getGenRandom() {
139 return genRandom;
140 }
141
142 public boolean wasAutoAdded() {
143 return wasAutoAdded;
144 }
145
146 public void setWasAutoAdded(boolean wasAutoAdded) {
147 this.wasAutoAdded = wasAutoAdded;
148 }
149
150 public boolean isActive() {
151 return isActive;
152 }
153
154 public void setActive(boolean isActive) {
155 this.isActive = isActive;
156 }
157
158}
static SettingsAPI getSettings()
Definition Global.java:51
PersonMissionSpec getMissionSpec(String id)