75 boolean onlyComputeIntervals,
76 TaskInterval [] intervals,
77 SectorEntityToken ... sequence) {
80 float totalFraction = 0f;
81 for (
int i = 0; i < intervals.length; i++) {
82 TaskInterval t = intervals[i];
83 if (t.type == IntervalType.TRAVEL_TIME) {
84 SectorEntityToken from = sequence[i];
85 SectorEntityToken to = sequence[i + 1];
91 if (t.type == IntervalType.FRACTION_OF_REMAINING) {
92 totalFraction += t.value;
98 if (totalFraction > 0) {
99 float remaining = maxDays - totalDays;
100 for (TaskInterval t : intervals) {
101 if (t.type == IntervalType.FRACTION_OF_REMAINING) {
102 t.value = Math.max(0.1f, t.value / totalFraction * remaining);
108 for (TaskInterval t : intervals) {
109 totalDays += t.value;
112 if (totalDays > maxDays) {
113 for (TaskInterval t : intervals) {
114 t.value *= maxDays / totalDays;
121 SectorEntityToken from =
null;
122 SectorEntityToken to =
null;
124 for (
int i = 0; i < intervals.length; i++) {
125 float curr = intervals[i].value;
126 if (curr < 0) curr = 0;
128 if (soFar + curr > daysElapsed && curr > 0) {
129 progress = (daysElapsed - soFar) / curr;
130 if (progress < 0) progress = 0;
131 if (progress > 1) progress = 1;
133 from = sequence[index];
134 to = sequence[index + 1];
135 intervals[i].value *= (1f - progress);
139 intervals[i].value = 0;
143 index = intervals.length - 1;
144 from = sequence[sequence.length - 2];
145 to = sequence[sequence.length - 1];
149 if (onlyComputeIntervals) {
170 float daysElapsed,
float maxDays,
int overflowIndex,
171 boolean onlyAdjustIntervals,
172 float [] intervals, SectorEntityToken ... sequence) {
175 for (
float curr : intervals) {
181 if (total != maxDays) {
182 if (overflowIndex >= 0) {
183 float extra = total - maxDays;
184 intervals[overflowIndex] -= extra;
185 if (intervals[overflowIndex] <= 0) {
186 total = maxDays - intervals[overflowIndex];
187 intervals[overflowIndex] = 0;
188 for (
int i = 0; i < intervals.length; i++) {
189 intervals[i] *= maxDays / total;
193 for (
int i = 0; i < intervals.length; i++) {
194 intervals[i] *= maxDays / total;
203 SectorEntityToken from =
null;
204 SectorEntityToken to =
null;
206 for (
int i = 0; i < intervals.length; i++) {
207 float curr = intervals[i];
208 if (curr < 0) curr = 0;
210 if (soFar + curr > daysElapsed && curr > 0) {
211 progress = (daysElapsed - soFar) / curr;
212 if (progress < 0) progress = 0;
213 if (progress > 1) progress = 1;
215 from = sequence[index];
216 to = sequence[index + 1];
217 intervals[i] *= (1f - progress);
225 index = intervals.length - 1;
226 from = sequence[sequence.length - 2];
227 to = sequence[sequence.length - 1];
232 if (onlyAdjustIntervals) {
242 float progress, SectorEntityToken from, SectorEntityToken to) {
254 if (progress < 0) progress = 0;
255 if (progress > 1) progress = 1;
257 if (to ==
null) to = from;
258 if (from ==
null) from = to;
260 if (from ==
null && to ==
null)
return;
264 SectorEntityToken forSystemCenterCheck =
null;
265 LocationAPI conLoc =
null;
268 conLoc = from.getContainingLocation();
269 forSystemCenterCheck = from;
271 if (!conLoc.isHyperspace()) {
272 if (progress > 0.03f) {
274 loc = Misc.getPointAtRadius(from.getLocation(), from.getRadius() + 100f + (
float) Math.random() * 100f);
276 loc =
new Vector2f(from.getLocation());
279 loc = Misc.getPointWithinRadius(from.getLocation(), 100f + 900f * varianceMult);
283 else if (from.isInHyperspace() && to.isInHyperspace()) {
284 conLoc = from.getContainingLocation();
285 loc = Misc.interpolateVector(from.getLocation(),
288 loc = Misc.getPointWithinRadius(loc, 100f + 900f * varianceMult);
291 else if (from.getContainingLocation() == to.getContainingLocation()) {
292 conLoc = from.getContainingLocation();
293 if (from.isSystemCenter()) forSystemCenterCheck = from;
294 if (to.isSystemCenter()) forSystemCenterCheck = to;
296 loc = Misc.interpolateVector(from.getLocation(),
299 if (conLoc instanceof StarSystemAPI &&
300 Misc.getDistance(loc,
new Vector2f()) < 2000) {
301 loc = Misc.getPointAtRadius(
new Vector2f(), 2000f);
303 loc = Misc.getPointWithinRadius(loc, 100f + 900f * varianceMult);
307 else if (from.isInHyperspace() != to.isInHyperspace()) {
308 SectorEntityToken inSystem = from;
309 SectorEntityToken inHyper = to;
311 if (from.isInHyperspace()) {
318 if (jp ==
null)
return;
319 float d1 = Misc.getDistance(inSystem, jp);
320 float d2 = Misc.getDistance(jp.getLocationInHyperspace(), inHyper.getLocation());
324 float t = d1 / (d1 + d2);
326 conLoc = inSystem.getContainingLocation();
327 forSystemCenterCheck = inSystem;
329 loc = Misc.interpolateVector(inSystem.getLocation(),
334 conLoc = inHyper.getContainingLocation();
335 loc = Misc.interpolateVector(Misc.getSystemJumpPointHyperExitLocation(jp),
336 inHyper.getLocation(),
340 loc = Misc.getPointWithinRadius(loc, 100f + 900f * varianceMult);
343 else if (from.getContainingLocation() != to.getContainingLocation()) {
348 if (jp1 ==
null || jp2 ==
null)
return;
349 float d1 = Misc.getDistance(from, jp1);
350 float d2 = Misc.getDistance(Misc.getSystemJumpPointHyperExitLocation(jp1),
351 Misc.getSystemJumpPointHyperExitLocation(jp1));
352 float d3 = Misc.getDistance(jp2, to);
357 float t1 = d1 / (d1 + d2 + d3);
358 float t2 = (d1 + d2) / (d1 + d2 + d3);
361 conLoc = from.getContainingLocation();
362 forSystemCenterCheck = from;
364 loc = Misc.interpolateVector(from.getLocation(),
368 }
else if (progress < t2) {
370 loc = Misc.interpolateVector(Misc.getSystemJumpPointHyperExitLocation(jp1),
371 Misc.getSystemJumpPointHyperExitLocation(jp2),
372 (progress - t1) / (t2 - t1));
375 conLoc = to.getContainingLocation();
376 forSystemCenterCheck = to;
378 loc = Misc.interpolateVector(jp2.getLocation(),
380 (progress - t2) / (1f - t2));
383 loc = Misc.getPointWithinRadius(loc, 100f + 900f * varianceMult);
387 if (forSystemCenterCheck !=
null && forSystemCenterCheck.isSystemCenter() &&
388 conLoc == forSystemCenterCheck.getContainingLocation()) {
389 loc = Misc.getPointAtRadius(forSystemCenterCheck.getLocation(), forSystemCenterCheck.getRadius() + 3000f + (
float) Math.random() * 2000f);
396 if (conLoc ==
null) conLoc = from.getContainingLocation();
397 if (loc ==
null) loc =
new Vector2f(from.getLocation());
400 if (fleet.getContainingLocation() != conLoc) {
401 if (fleet.getContainingLocation() !=
null) {
402 fleet.getContainingLocation().removeEntity(fleet);
404 conLoc.addEntity(fleet);
406 fleet.setLocation(loc.x, loc.y);
425 float min = Float.MAX_VALUE;
426 JumpPointAPI result =
null;
428 JumpPointAPI fringe =
null;
430 LocationAPI location = from.getContainingLocation();
431 List<JumpPointAPI> points = location.getEntities(JumpPointAPI.class);
434 for (JumpPointAPI curr : points) {
438 if (curr.getMemoryWithoutUpdate().getBoolean(WormholeManager.WORMHOLE)) {
442 float dist = Misc.getDistance(from.getLocation(), curr.getLocation());
447 dist = Misc.getDistance(
new Vector2f(), curr.getLocation());
448 if (dist > fringeMax) {
454 if (from.getContainingLocation() instanceof StarSystemAPI) {
455 StarSystemAPI system = (StarSystemAPI) from.getContainingLocation();
457 if (useFringeOnly && fringe !=
null) {