1package com.fs.starfarer.api.impl.campaign.ghosts;
3import java.util.ArrayList;
4import java.util.Iterator;
6import java.util.Random;
8import com.fs.starfarer.api.EveryFrameScript;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.CampaignFleetAPI;
11import com.fs.starfarer.api.campaign.SectorEntityToken;
12import com.fs.starfarer.api.impl.campaign.ghosts.types.AbyssalDrifterGhostCreator;
13import com.fs.starfarer.api.impl.campaign.ghosts.types.ChargerGhostCreator;
14import com.fs.starfarer.api.impl.campaign.ghosts.types.EchoGhostCreator;
15import com.fs.starfarer.api.impl.campaign.ghosts.types.EncounterTricksterGhostCreator;
16import com.fs.starfarer.api.impl.campaign.ghosts.types.GuideGhostCreator;
17import com.fs.starfarer.api.impl.campaign.ghosts.types.LeviathanCalfGhostCreator;
18import com.fs.starfarer.api.impl.campaign.ghosts.types.LeviathanGhostCreator;
19import com.fs.starfarer.api.impl.campaign.ghosts.types.MinnowGhostCreator;
20import com.fs.starfarer.api.impl.campaign.ghosts.types.NoGhostCreator;
21import com.fs.starfarer.api.impl.campaign.ghosts.types.RacerGhostCreator;
22import com.fs.starfarer.api.impl.campaign.ghosts.types.RemnantGhostCreator;
23import com.fs.starfarer.api.impl.campaign.ghosts.types.RemoraGhostCreator;
24import com.fs.starfarer.api.impl.campaign.ghosts.types.ShipGhostCreator;
25import com.fs.starfarer.api.impl.campaign.ghosts.types.StormTricksterGhostCreator;
26import com.fs.starfarer.api.impl.campaign.ghosts.types.StormcallerGhostCreator;
27import com.fs.starfarer.api.impl.campaign.ghosts.types.ZigguratGhostCreator;
28import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
29import com.fs.starfarer.api.util.Misc;
30import com.fs.starfarer.api.util.TimeoutTracker;
31import com.fs.starfarer.api.util.WeightedRandomPicker;
35 public static List<SensorGhostCreator>
CREATORS =
new ArrayList<SensorGhostCreator>();
38 CREATORS.add(
new ChargerGhostCreator());
39 CREATORS.add(
new EchoGhostCreator());
40 CREATORS.add(
new EncounterTricksterGhostCreator());
41 CREATORS.add(
new GuideGhostCreator());
42 CREATORS.add(
new LeviathanGhostCreator());
43 CREATORS.add(
new LeviathanCalfGhostCreator());
44 CREATORS.add(
new MinnowGhostCreator());
46 CREATORS.add(
new RacerGhostCreator());
47 CREATORS.add(
new RemnantGhostCreator());
48 CREATORS.add(
new RemoraGhostCreator());
49 CREATORS.add(
new ShipGhostCreator());
50 CREATORS.add(
new StormcallerGhostCreator());
51 CREATORS.add(
new StormTricksterGhostCreator());
52 CREATORS.add(
new ZigguratGhostCreator());
53 CREATORS.add(
new AbyssalDrifterGhostCreator());
79 protected Random
random =
new Random(Misc.genRandomSeed());
80 protected List<SensorGhost>
ghosts =
new ArrayList<SensorGhost>();
84 String ghostManagerKey =
"$ghostManager";
86 if (manager ==
null) {
90 Global.
getSector().getMemoryWithoutUpdate().set(ghostManagerKey, manager);
100 if (manager ==
null)
return null;
103 if (ghost.getEntity() == entity) {
111 if (amount == 0)
return;
113 if (pf ==
null)
return;
117 if (Misc.getAbyssalDepth(pf) >= 1f) {
136 Iterator<SensorGhost> iter =
ghosts.iterator();
137 while (iter.hasNext()) {
153 if (
Global.
getSector().getMemoryWithoutUpdate().getBoolean(MemFlags.GLOBAL_SENSOR_BURST_JUST_USED_IN_CURRENT_LOCATION)) {
161 for (CampaignFleetAPI fleet :
Global.
getSector().getCurrentLocation().getFleets()) {
162 float dist = Misc.getDistance(fleet.getLocation(), pf.getLocation());
163 if (dist > range)
continue;
164 if (fleet.getMemoryWithoutUpdate().getBoolean(MemFlags.JUST_DID_SENSOR_BURST)) {
176 boolean nearStream = Misc.isInsideSlipstream(pf.getLocation(), 1000f, pf.getContainingLocation());
178 boolean inAbyss = Misc.isInAbyss(pf);
180 WeightedRandomPicker<SensorGhostCreator> picker =
new WeightedRandomPicker<SensorGhostCreator>(
random);
183 if (nearStream && !creator.canSpawnWhilePlayerInOrNearSlipstream())
continue;
184 if (inAbyss && !creator.canSpawnWhilePlayerInAbyss())
continue;
185 if (!inAbyss && !creator.canSpawnWhilePlayerOutsideAbyss())
continue;
187 float freq = creator.getFrequency(
this);
188 picker.add(creator, freq);
192 if (creator ==
null)
return;
196 boolean canSpawn =
true;
206 List<SensorGhost>
ghosts =
null;
210 boolean anyFailed =
false;
213 anyFailed |= curr.isCreationFailed();
226 this.ghosts.addAll(
ghosts);
241 if (clazz.isInstance(ghost))
return true;
static SectorAPI getSector()
static SensorGhostManager getGhostManager()
List< SensorGhost > ghosts
static float GHOST_SPAWN_RATE_MULT
static float MIN_SHORT_GHOST_TIMEOUT_DAYS
static float SB_FAILED_TO_ATTRACT_TIMEOUT_MULT
boolean hasGhostOfClass(Class<?> clazz)
static float MAX_FULL_GHOST_TIMEOUT_DAYS
static float MIN_SB_TIMEOUT
static float MAX_SB_TIMEOUT
static List< SensorGhostCreator > CREATORS
static float MAX_SHORT_GHOST_TIMEOUT_DAYS
static float MAX_FAILED_CREATOR_TIMEOUT_DAYS
static float FULL_TIMEOUT_TRIGGER_PROBABILITY
List< SensorGhost > getGhosts()
static SensorGhost getGhostFor(SectorEntityToken entity)
void advance(float amount)
static float MIN_FULL_GHOST_TIMEOUT_DAYS
TimeoutTracker< String > perCreatorTimeouts
static float MIN_FAILED_CREATOR_TIMEOUT_DAYS
boolean spawnTriggeredBySensorBurst
static float SB_ATTRACT_GHOSTS_PROBABILITY
static float GHOST_SPAWN_RATE_MULT_IN_ABYSS
boolean isSpawnTriggeredBySensorBurst()
void advance(float amount)
List< SensorGhost > createGhost(SensorGhostManager manager)
boolean canSpawnWhilePlayerInAbyss()
float getTimeoutDaysOnSuccessfulCreate(SensorGhostManager manager)