Starsector API
Loading...
Searching...
No Matches
ConstructionSwarmSystemAI.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat.threat;
2
3import org.lwjgl.util.vector.Vector2f;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.combat.CombatEngineAPI;
7import com.fs.starfarer.api.combat.CombatFleetManagerAPI;
8import com.fs.starfarer.api.combat.ShipAPI;
9import com.fs.starfarer.api.combat.ShipCommand;
10import com.fs.starfarer.api.combat.ShipSystemAIScript;
11import com.fs.starfarer.api.combat.ShipSystemAPI;
12import com.fs.starfarer.api.combat.ShipwideAIFlags;
13import com.fs.starfarer.api.util.IntervalUtil;
14
15
17
18 public static float REQUIRED_DP_FOR_NORMAL_USE = 35;
19
20 protected ShipAPI ship;
24 //protected ConstructionSwarmSystemScript script;
25
26 protected IntervalUtil tracker = new IntervalUtil(0.5f, 1f);
27
28 protected float keepUsingFor = 0f;
29 protected float timeSpentAtHighFragmentLevel = 0f;
30
32 this.ship = ship;
33 this.flags = flags;
34 this.engine = engine;
35 this.system = system;
36
37 // can't actual use this here this way due to class load order dependency making the game crash on startup
38 //script = (ConstructionSwarmSystemScript)system.getScript();
39 }
40
41 public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target) {
42 tracker.advance(amount);
43
44 keepUsingFor -= amount;
45
46 if (tracker.intervalElapsed()) {
47 if (system.getCooldownRemaining() > 0) return;
48 if (system.isOutOfAmmo()) return;
49 if (system.isActive()) return;
50
51
53 if (!script.isUsable(system, ship)) {
54 return;
55 }
56
58 int dpLeft = 0;
59 if (manager != null) {
60 dpLeft = manager.getMaxStrength() - manager.getCurrStrength();
61 }
62
63 float cr = ship.getCurrentCR();
64 float softFlux = ship.getFluxLevel();
65 float hardFlux = ship.getHardFluxLevel();
66
67 if (cr < 0.2f + hardFlux * 0.2f) {
68 return;
69 }
70
72 if (swarm == null) return;
73
74 int active = swarm.getNumActiveMembers();
75 int max = swarm.getNumMembersToMaintain();
76
77 if (active >= max * 0.9f) {
79 } else {
81 }
82
83
84
85 if ((active >= max || timeSpentAtHighFragmentLevel >= 10f) && dpLeft >= REQUIRED_DP_FOR_NORMAL_USE) {
86 keepUsingFor = 3f + (float) Math.random() * 2f;
87 }
88
89 if (keepUsingFor <= 0f && (hardFlux > 0.5f || softFlux > 0.9f)) {
90 keepUsingFor = 0.5f;
91 }
92
93 if (keepUsingFor > 0f) {
95 }
96 }
97 }
98
99}
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
static CombatEngineAPI getCombatEngine()
Definition Global.java:69
void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine)
void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target)
static RoilingSwarmEffect getSwarmFor(CombatEntityAPI entity)
CombatFleetManagerAPI getFleetManager(FleetSide side)
void giveCommand(ShipCommand command, Object param, int groupNumber)