1package com.fs.starfarer.api.impl.campaign.terrain;
3import java.util.ArrayList;
5import java.util.Random;
7import org.lwjgl.util.vector.Vector2f;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.CampaignFleetAPI;
11import com.fs.starfarer.api.campaign.LocationAPI;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
13import com.fs.starfarer.api.impl.campaign.enc.EncounterPoint;
14import com.fs.starfarer.api.impl.campaign.enc.EncounterPointProvider;
15import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.StarSystemType;
16import com.fs.starfarer.api.util.Misc;
39 public static class AbyssalEPData {
42 public StarSystemAPI nearest =
null;
43 public float distToNearest = Float.MAX_VALUE;
51 protected Random
random =
new Random();
69 float baseW = 100000f;
72 float normalizedX = (loc.x + w/2f) / baseW;
73 float normalizedY = (loc.y + h/2f) / baseH;
76 if (normalizedX >= 0 && normalizedY >= 0) {
77 test = (float) (Math.sqrt(normalizedX) + Math.sqrt(normalizedY));
78 }
else if (normalizedX < 0 && (loc.y + h/2f) < baseH) {
80 }
else if (normalizedY < 0 && (loc.x + w/2f) < baseW) {
85 float threshold = 0.95f;
86 if (test < threshold)
return 1f;
88 return 1f - (test - threshold) / (1f - threshold);
92 float left = -w/2f - loc.x;
93 float below = -h/2f - loc.y;
94 float right = loc.x - w/2f;
95 float above = loc.y - h/2f;
97 float max = Math.max(left, Math.max(right, Math.max(above, below)));
99 return Math.min(1f, max / 2000f);
117 List<StarSystemAPI> abyssal =
new ArrayList<StarSystemAPI>();
119 float depth = Misc.getAbyssalDepth(system.getLocation());
130 if (!where.isHyperspace())
return null;
136 Vector2f loc = pf.getLocation();
148 float startAngle =
random.nextFloat() * 360f;
149 for (
float angle = startAngle; angle < startAngle + 360f; angle += 30f) {
150 Vector2f loc = Misc.getUnitVectorAtDegreeAngle(angle);
154 loc = Misc.getPointWithinRadius(loc, 1000f,
random);
163 String
id =
"abyssal_" + (int)(loc.x/1000f) +
"_" + (int)(loc.y/1000f);
164 EncounterPoint point =
new EncounterPoint(
id, where, loc,
EP_TYPE_ABYSSAL);
166 AbyssalEPData data =
new AbyssalEPData();
168 data.random = Misc.getRandom(
random.nextLong(), 7);
170 float minDist = Float.MAX_VALUE;
171 StarSystemAPI nearest =
null;
172 for (StarSystemAPI system : abyssal) {
173 float distToSystem = Misc.getDistance(system.getLocation(), loc);
175 if (system.getType() == StarSystemType.DEEP_SPACE) {
178 if (distToSystem < testDist && distToSystem < minDist) {
179 minDist = distToSystem;
183 if (nearest !=
null) {
184 data.nearest = nearest;
185 data.distToNearest = minDist;
static SettingsAPI getSettings()
static SectorAPI getSector()
Vector2f playerLocWhenGeneratingEPs
static float DEPTH_THRESHOLD_FOR_FLEETS_FLEEING
static float JUMP_POINT_DETECTED_RANGE
static float NASCENT_WELL_DETECTED_RANGE
List< StarSystemAPI > getAbyssalSystems()
List< EncounterPoint > generateEncounterPoints(LocationAPI where)
HyperspaceAbyssPluginImpl()
void advance(float amount)
static float DEPTH_THRESHOLD_FOR_ABYSSAL_LIGHT
static float GAS_GIANT_DETECTED_RANGE
static float PLAYER_DIST_TRAVELLED_TO_REGEN_EPS
static float DEPTH_THRESHOLD_FOR_ABYSSAL_STELLAR_OBJECT
static float DEPTH_THRESHOLD_FOR_ABYSSAL_STAR_SYSTEM
static float DEPTH_THRESHOLD_FOR_ENCOUNTER
float getAbyssalDepth(Vector2f loc)
static float ENCOUNTER_NEAR_ABYSSAL_SYSTEM_DIST
static float DEPTH_THRESHOLD_FOR_NO_DUST_PARTICLES_IN_COMBAT
static float STAR_DETECTED_RANGE
static String EP_TYPE_ABYSSAL
List< EncounterPoint > encounterPoints
float getFloat(String key)