Starsector API
Loading...
Searching...
No Matches
BaseEPEncounterCreator.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.enc;
2
3import org.lwjgl.util.vector.Vector2f;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.StarSystemAPI;
7import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
8import com.fs.starfarer.api.impl.campaign.ids.Tags;
9import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathBaseIntel;
10import com.fs.starfarer.api.impl.campaign.intel.bases.PirateBaseIntel;
11import com.fs.starfarer.api.util.Misc;
12
15 public static float PATHER_AMBUSH_MAX_RANGE = 16000f;
16
18 public static float PIRATE_AMBUSH_MAX_RANGE = 16000f;
19
20 public static float RUINS_RANGE_FOR_FULL_PROXIMITY_FACTOR = 4000f;
21 public static float RUINS_MAX_RANGE = 16000f;
22
23 public static float CORE_PROXIMITY_MAX_RANGE = 30000f;
24
25
26 public String getId() {
27 return getClass().getSimpleName();
28 }
29
30 public float getPointTimeoutMin() {
31 return 30f;
32 }
33 public float getPointTimeoutMax() {
34 return 90f;
35 }
36
37 public float getCreatorTimeoutMin() {
38 return 0;
39 }
40
41 public float getCreatorTimeoutMax() {
42 return 0;
43 }
44
46 return 10f;
47 }
48
49 public void createEncounter(EncounterManager manager, EncounterPoint point) {
50 }
51
52
53
54 public static float getLuddicPathBaseProximityFactor(LuddicPathBaseIntel base, Vector2f locInHyper) {
55 if (base == null) return 0f;
56 float dist = Misc.getDistance(base.getEntity().getLocationInHyperspace(), locInHyper);
58 return 1f;
59 }
61 if (f < 0f) f = 0f;
62 if (f > 1f) f = 1f;
63 return f;
64
65 }
66 public static LuddicPathBaseIntel getClosestLuddicPathBase(Vector2f locInHyper) {
67 return getClosestLuddicPathBase(locInHyper, true);
68 }
69 public static LuddicPathBaseIntel getClosestLuddicPathBase(Vector2f locInHyper, boolean onlyInProximity) {
70 LuddicPathBaseIntel closest = null;
71 float minDist = Float.MAX_VALUE;
72 for (IntelInfoPlugin p : Global.getSector().getIntelManager().getIntel(LuddicPathBaseIntel.class)) {
73 LuddicPathBaseIntel intel = (LuddicPathBaseIntel) p;
74 if (intel.getEntity() == null || !intel.getEntity().isAlive()) continue;
75 float dist = Misc.getDistance(intel.getEntity().getLocationInHyperspace(), locInHyper);
76 if (onlyInProximity && dist > PATHER_AMBUSH_MAX_RANGE) continue;
77 if (dist < minDist) {
78 minDist = dist;
79 closest = intel;
80 }
81 }
82 return closest;
83 }
84
85 public static float getPirateBaseProximityFactor(PirateBaseIntel base, Vector2f locInHyper) {
86 if (base == null) return 0f;
87 float dist = Misc.getDistance(base.getEntity().getLocationInHyperspace(), locInHyper);
89 return 1f;
90 }
92 if (f < 0f) f = 0f;
93 if (f > 1f) f = 1f;
94 return f;
95
96 }
97 public static PirateBaseIntel getClosestPirateBase(Vector2f locInHyper) {
98 return getClosestPirateBase(locInHyper, true);
99 }
100 public static PirateBaseIntel getClosestPirateBase(Vector2f locInHyper, boolean onlyInProximity) {
101 PirateBaseIntel closest = null;
102 float minDist = Float.MAX_VALUE;
103 for (IntelInfoPlugin p : Global.getSector().getIntelManager().getIntel(PirateBaseIntel.class)) {
104 PirateBaseIntel intel = (PirateBaseIntel) p;
105 if (intel.getEntity() == null || !intel.getEntity().isAlive()) continue;
106 float dist = Misc.getDistance(intel.getEntity().getLocationInHyperspace(), locInHyper);
107 if (onlyInProximity && dist > PIRATE_AMBUSH_MAX_RANGE) continue;
108 if (dist < minDist) {
109 minDist = dist;
110 closest = intel;
111 }
112 }
113 return closest;
114 }
115
116
117 public static float getCoreProximityFactor(Vector2f locInHyper) {
118 Vector2f min = Misc.getCoreMin();
119 Vector2f max = Misc.getCoreMax();
120 Vector2f core = Misc.getCoreCenter();
121
122 float across = Misc.getDistance(min, max);
123 float fullProximityAt = across * 0.5f;
124 fullProximityAt = Math.min(CORE_PROXIMITY_MAX_RANGE / 2f, fullProximityAt);
125
126 float dist = Misc.getDistance(core, locInHyper);
127 if (dist < fullProximityAt) {
128 return 1f;
129 }
130 float f = 1f - (dist - fullProximityAt) / (CORE_PROXIMITY_MAX_RANGE - fullProximityAt);
131 if (f < 0f) f = 0f;
132 if (f > 1f) f = 1f;
133 return f;
134 }
135
136 public static float getRuinsProximityFactor(StarSystemAPI system, Vector2f locInHyper) {
137 if (system == null) return 0f;
138 float dist = Misc.getDistance(system.getLocation(), locInHyper);
140 return 1f;
141 }
143 if (f < 0f) f = 0f;
144 if (f > 1f) f = 1f;
145 return f;
146 }
147
148
149 public static StarSystemAPI getClosestSystemWithRuins(Vector2f locInHyper) {
150 return getClosestSystemWithRuins(locInHyper, true);
151 }
152 public static StarSystemAPI getClosestSystemWithRuins(Vector2f locInHyper, boolean onlyInProximity) {
153 StarSystemAPI closest = null;
154 float minDist = Float.MAX_VALUE;
155 for (StarSystemAPI curr : Global.getSector().getStarSystems()) {
156 if (curr.hasTag(Tags.THEME_RUINS_MAIN)) {
157 float dist = Misc.getDistance(curr.getLocation(), locInHyper);
158 if (onlyInProximity && dist > RUINS_MAX_RANGE) continue;
159 if (dist < minDist) {
160 minDist = dist;
161 closest = curr;
162 }
163 }
164 }
165 return closest;
166 }
167}
static SectorAPI getSector()
Definition Global.java:59
static LuddicPathBaseIntel getClosestLuddicPathBase(Vector2f locInHyper, boolean onlyInProximity)
static float getRuinsProximityFactor(StarSystemAPI system, Vector2f locInHyper)
void createEncounter(EncounterManager manager, EncounterPoint point)
static float getLuddicPathBaseProximityFactor(LuddicPathBaseIntel base, Vector2f locInHyper)
static PirateBaseIntel getClosestPirateBase(Vector2f locInHyper, boolean onlyInProximity)
static StarSystemAPI getClosestSystemWithRuins(Vector2f locInHyper, boolean onlyInProximity)
static PirateBaseIntel getClosestPirateBase(Vector2f locInHyper)
float getFrequencyForPoint(EncounterManager manager, EncounterPoint point)
static float getPirateBaseProximityFactor(PirateBaseIntel base, Vector2f locInHyper)
static LuddicPathBaseIntel getClosestLuddicPathBase(Vector2f locInHyper)