476 Iterator<AddedStream> iter =
active.iterator();
477 while (iter.hasNext()) {
478 AddedStream curr = iter.next();
479 if (!curr.terrain.isAlive()) {
486 if (month == 6 || month == 12) {
487 for (AddedStream curr :
active) {
488 if (curr.plugin.isDespawning())
continue;
489 float despawnDelay = 0f +
random.nextFloat() * 20f;
490 float timeMinusDelay = 27f - despawnDelay;
491 float despawnDays = timeMinusDelay * 0.5f +
random.nextFloat() * timeMinusDelay * 0.5f;
492 curr.plugin.despawn(despawnDelay, despawnDays,
random);
498 }
else if (month != 6 && month != 12) {
505 WeightedRandomPicker<String> picker =
new WeightedRandomPicker<String>(
random);
515 ListenerUtil.updateSlipstreamConfig(
prevConfig, picker,
this);
516 String data = picker.pick();
532 if (
config ==
null)
return;
539 WeightedRandomPicker<StreamData> picker =
new WeightedRandomPicker<StreamData>(
random);
540 for (StreamData data :
config.streams) {
541 if (data.wasUsed)
continue;
542 if (!data.priority)
continue;
545 if (picker.isEmpty()) {
547 for (StreamData data :
config.streams) {
548 if (data.wasUsed)
continue;
553 StreamData data = picker.pick();
554 if (data ==
null)
return;
556 SlipstreamParams2 params =
new SlipstreamParams2();
557 params.burnLevel = 30 + data.burnMod;
558 params.minSpeed = Misc.getSpeedForBurnLevel(params.burnLevel - 5);
559 params.maxSpeed = Misc.getSpeedForBurnLevel(params.burnLevel + 5);
560 params.lineLengthFractionOfSpeed = 0.25f * Math.max(0.25f, Math.min(1f, 30f / (
float) params.burnLevel));
563 Vector2f from = data.generateP0(
random);
564 Vector2f to = data.generateP1(
random);
565 Vector2f control = data.generateControl(
random);
566 Vector2f control2 = data.generateControl2(
random);
567 if (from ==
null || to ==
null)
return;
571 if (month == 12 || month < 6) {
573 if ((!data.reverse && from.x > to.x) || (data.reverse && from.x < to.x)) {
579 if ((!data.reverse && from.x < to.x) || (data.reverse && from.x > to.x)) {
588 CampaignTerrainAPI slipstream = (CampaignTerrainAPI) hyperspace.addTerrain(Terrain.SLIPSTREAM, params);
590 slipstream.setLocation(from.x, from.y);
600 if (control2 !=
null) {
601 float dist1 = Misc.getDistance(from, control);
602 float dist2 = Misc.getDistance(from, control2);
604 Vector2f temp = control2;
609 }
else if (control !=
null) {
618 hyperspace.removeEntity(slipstream);
622 float spawnDays = 1f + 2f *
random.nextFloat();
630 AddedStream added =
new AddedStream(plugin);
640 List<SlipstreamSegment> segments = plugin.
getSegments();
642 Set<SlipstreamSegment> otherStreamCuts =
new HashSet<SlipstreamSegment>();
644 for (SlipstreamSegment curr : segments) {
646 Iterator<Object> iter =
grid.getCheckIterator(curr.loc, curr.width / 2f, curr.width / 2f);
647 while (iter.hasNext()) {
648 Object obj = iter.next();
649 if (obj instanceof JumpPointAPI) {
650 JumpPointAPI jp = (JumpPointAPI) obj;
651 Vector2f loc = jp.getLocation();
652 float radius = jp.getRadius();
653 if (jp.getOrbitFocus() !=
null) {
654 loc = jp.getOrbitFocus().getLocation();
655 radius = Misc.getDistance(jp.getOrbitFocus(), jp) + jp.getRadius();
658 Vector2f diff = Vector2f.sub(loc, curr.loc,
new Vector2f());
660 float distPerp = Math.abs(Vector2f.dot(curr.normal, diff));
661 float distAlong = Math.abs(Vector2f.dot(curr.dir, diff));
666 float minDistAlong = Math.max(curr.lengthToNext, curr.lengthToPrev);
667 float fadeDistAlong = 500f + minDistAlong;
668 if (distPerp < curr.width / 2f &&
669 distAlong < fadeDistAlong) {
670 if (distAlong < minDistAlong) {
671 curr.fader.forceOut();
674 curr.bMult = Math.min(curr.bMult,
675 (distAlong - minDistAlong) / (fadeDistAlong - minDistAlong));
678 }
else if (obj instanceof CampaignTerrainAPI) {
679 CampaignTerrainAPI terrain = (CampaignTerrainAPI) obj;
681 if (otherPlugin == plugin)
continue;
683 for (SlipstreamSegment other : otherPlugin.
getSegmentsNear(curr.loc, curr.width / 2f)) {
685 if (other.bMult <= 0)
continue;
687 float dist = Misc.getDistance(curr.loc, other.loc);
688 float minDist = curr.width / 2f + other.width / 2f;
689 float fadeDist = minDist + 500f;
690 if (dist < fadeDist) {
691 if (dist < minDist) {
692 curr.fader.forceOut();
694 otherStreamCuts.add(curr);
696 curr.bMult = Math.min(curr.bMult,
697 (dist - minDist) / (fadeDist - minDist));
701 }
else if (obj instanceof CustomStreamBlocker) {
702 CustomStreamBlocker blocker = (CustomStreamBlocker) obj;
703 Vector2f loc = blocker.loc;
704 float radius = blocker.radius;
706 Vector2f diff = Vector2f.sub(loc, curr.loc,
new Vector2f());
707 float distPerp = Math.abs(Vector2f.dot(curr.normal, diff));
708 float distAlong = Math.abs(Vector2f.dot(curr.dir, diff));
713 float minDistAlong = Math.max(curr.lengthToNext, curr.lengthToPrev);
714 float fadeDistAlong = 500f + minDistAlong;
715 if (distPerp < curr.width / 2f &&
716 distAlong < fadeDistAlong) {
717 if (distAlong < minDistAlong) {
718 curr.fader.forceOut();
721 curr.bMult = Math.min(curr.bMult,
722 (distAlong - minDistAlong) / (fadeDistAlong - minDistAlong));
725 }
else if (obj instanceof AbyssStreamBlocker) {
726 AbyssStreamBlocker abyss = (AbyssStreamBlocker) obj;
727 if (abyss.containsPoint(curr.loc)) {
728 curr.fader.forceOut();
743 if (onlyKeepLongestBetweenStreams) {
748 for (SlipstreamSegment curr : segments) {
749 if (otherStreamCuts.contains(curr)) {
750 if (currList.size() > longest.size()) {
753 currList =
new ArrayList<SlipstreamSegment>();
755 if (curr.bMult > 0f) {
759 if (currList.size() > longest.size()) {
762 for (SlipstreamSegment curr : segments) {
763 if (!longest.contains(curr)) {
765 curr.fader.forceOut();
852 if (
grid !=
null)
return;
856 float minCellSize = 12000f;
857 float cellSize = Math.max(minCellSize, sw * 0.05f);
859 grid =
new CollisionGridUtil(-sw/2f, sw/2f, -sh/2f, sh/2f, cellSize);
862 for (SectorEntityToken jp : hyperspace.getJumpPoints()) {
863 float size = jp.getRadius() * 2f + 100f;
864 grid.addObject(jp, jp.getLocation(), size * 2f, size * 2f);
872 Object alphaSiteWell =
Global.
getSector().getMemoryWithoutUpdate().get(TTBlackSite.NASCENT_WELL_KEY);
873 if (alphaSiteWell instanceof NascentGravityWellAPI) {
874 NascentGravityWellAPI well = (NascentGravityWellAPI) alphaSiteWell;
875 float size = 1000f + well.getRadius();
876 CustomStreamBlocker blocker =
new CustomStreamBlocker(well.getLocation(), size);
877 grid.addObject(blocker, well.getLocation(), size * 2f, size * 2f);
881 if (system.hasTag(Tags.THEME_CORE)) {
882 Vector2f loc = system.getLocation();
884 CustomStreamBlocker blocker =
new CustomStreamBlocker(loc, size);
885 grid.addObject(blocker, loc, size * 2f, size * 2f);
896 AbyssStreamBlocker orionPersusAbyssBlocker =
new AbyssStreamBlocker();
897 grid.addObject(orionPersusAbyssBlocker,
new Vector2f(), w, h);
913 int segmentsToSkip = (int) ((cellSize - 2000) / 400f);
914 float checkSize = minCellSize - 2000f;
916 for (CampaignTerrainAPI curr : hyperspace.getTerrainCopy()) {
919 List<SlipstreamSegment> segments = plugin.
getSegments();
921 for (
int i = 0; i < segments.size(); i += segmentsToSkip) {
922 check.add(segments.get(i));
924 if (!check.contains(segments.get(segments.size() - 1))) {
925 check.add(segments.get(segments.size() - 1));
928 for (SlipstreamSegment seg : check) {
929 grid.addObject(curr, seg.loc, checkSize, checkSize);
934 ListenerUtil.updateSlipstreamBlockers(
grid,
this);