Starsector API
Loading...
Searching...
No Matches
AbyssalLightEPEC.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.SectorEntityToken;
7import com.fs.starfarer.api.impl.campaign.AbyssalLightEntityPlugin;
8import com.fs.starfarer.api.impl.campaign.AbyssalLightEntityPlugin.AbyssalLightParams;
9import com.fs.starfarer.api.impl.campaign.ids.Entities;
10import com.fs.starfarer.api.impl.campaign.ids.Factions;
11import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceAbyssPluginImpl.AbyssalEPData;
12import com.fs.starfarer.api.util.Misc;
13import com.fs.starfarer.api.util.WeightedRandomPicker;
14
16
17 public static enum LightSpawnType {
18 NORMAL,
19 PAIR,
20 CLUSTER,
21 LARGE,
22 }
23
25// if (!HyperspaceAbyssPluginImpl.EP_TYPE_ABYSSAL.equals(point.type)) return 0f;
26// AbyssalEPData data = (AbyssalEPData) point.custom;
27// if (data.depth < HyperspaceAbyssPluginImpl.DEPTH_THRESHOLD_FOR_ABYSSAL_LIGHT) return 0f;
28// if (data.nearest != null) return 0f;
29//
30// return 1f;
31 return AbyssalFrequencies.getAbyssalLightFrequency(manager, point);
32 }
33
34
35 @Override
36 public void createEncounter(EncounterManager manager, EncounterPoint point) {
37
38 AbyssalEPData data = (AbyssalEPData) point.custom;
39
40 WeightedRandomPicker<LightSpawnType> picker = new WeightedRandomPicker<LightSpawnType>(data.random);
41 picker.add(LightSpawnType.NORMAL, 100f);
42 picker.add(LightSpawnType.PAIR, 7f);
43 picker.add(LightSpawnType.CLUSTER, 3f);
44 picker.add(LightSpawnType.LARGE, 1f);
45
46 LightSpawnType type = picker.pick();
47
48 float minSize = AbyssalLightEntityPlugin.MIN_SIZE;
49 float maxSize = AbyssalLightEntityPlugin.MAX_SIZE;
50 if (type == LightSpawnType.NORMAL) {
51 AbyssalLightParams params = new AbyssalLightParams();
52 SectorEntityToken e = Global.getSector().getHyperspace().addCustomEntity(
53 null, null, Entities.ABYSSAL_LIGHT, Factions.NEUTRAL, params);
54 e.setLocation(point.loc.x, point.loc.y);
55 } else if (type == LightSpawnType.LARGE) {
56 AbyssalLightParams params = new AbyssalLightParams(maxSize + 800f, maxSize + 1200f);
57 params.durationDays = 1000f + data.random.nextFloat() * 500f;
58 params.frequencyChangeMult = 0.25f;
59
60 SectorEntityToken e = Global.getSector().getHyperspace().addCustomEntity(
61 null, null, Entities.ABYSSAL_LIGHT, Factions.NEUTRAL, params);
62 e.setLocation(point.loc.x, point.loc.y);
63 } else if (type == LightSpawnType.PAIR) {
64 AbyssalLightParams larger = new AbyssalLightParams(maxSize - 300f, maxSize + 300f);
65 larger.durationDays = 90f + data.random.nextFloat() * 30f;
66 larger.frequencyChangeMult = 0.75f;
67
68 SectorEntityToken e = Global.getSector().getHyperspace().addCustomEntity(
69 null, null, Entities.ABYSSAL_LIGHT, Factions.NEUTRAL, larger);
70 e.setLocation(point.loc.x, point.loc.y);
71
72 AbyssalLightParams smaller = new AbyssalLightParams(minSize * 0.2f, minSize * 0.5f);
73 smaller.durationDays = larger.durationDays;
74 smaller.frequencyChangeMult = larger.frequencyChangeMult;
75
76 Vector2f loc = Misc.getPointAtRadius(point.loc, 100f + data.random.nextFloat() * 300f);
77 e = Global.getSector().getHyperspace().addCustomEntity(
78 null, null, Entities.ABYSSAL_LIGHT, Factions.NEUTRAL, smaller);
79 e.setLocation(loc.x, loc.y);
80 } else if (type == LightSpawnType.CLUSTER) {
81 int num = 3 + data.random.nextInt(7);
82 float spread = 50f + num * 10f;
83 spread *= 0.5f;
84 for (int i = 0; i < num; i++) {
85 AbyssalLightParams params = new AbyssalLightParams(minSize * 0.1f, minSize * 0.2f);
86 params.durationDays += data.random.nextFloat() * 50f;
87 params.frequencyChangeMult = 2f + data.random.nextFloat() * 2f;;
88 params.frequencyMultMin *= params.frequencyChangeMult;
89 params.frequencyMultMax *= params.frequencyChangeMult;
90
91 //Vector2f loc = Misc.getPointWithinRadiusUniform(point.loc, spread, data.random);
92 Vector2f loc = Misc.getPointWithinRadius(point.loc, spread);
93 SectorEntityToken e = Global.getSector().getHyperspace().addCustomEntity(
94 null, null, Entities.ABYSSAL_LIGHT, Factions.NEUTRAL, params);
95 e.setLocation(loc.x, loc.y);
96 }
97 }
98
99 }
100
101}
102
103
104
105
106
107
108
109
110
111
112
113
114
static SectorAPI getSector()
Definition Global.java:59
static float getAbyssalLightFrequency(EncounterManager manager, EncounterPoint point)
float getFrequencyForPoint(EncounterManager manager, EncounterPoint point)
void createEncounter(EncounterManager manager, EncounterPoint point)