Starsector API
Loading...
Searching...
No Matches
NeuralInterface.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.GameState;
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.combat.BaseHullMod;
8import com.fs.starfarer.api.combat.MutableShipStatsAPI;
9import com.fs.starfarer.api.combat.ShipAPI;
10import com.fs.starfarer.api.combat.ShipAPI.HullSize;
11import com.fs.starfarer.api.combat.ShipHullSpecAPI.ShipTypeHints;
12import com.fs.starfarer.api.combat.ShipSystemAPI;
13import com.fs.starfarer.api.impl.campaign.ids.Stats;
14import com.fs.starfarer.api.impl.campaign.ids.Strings;
15import com.fs.starfarer.api.impl.campaign.skills.NeuralLinkScript;
16import com.fs.starfarer.api.impl.campaign.skills.SupportDoctrine;
17import com.fs.starfarer.api.ui.Alignment;
18import com.fs.starfarer.api.ui.TooltipMakerAPI;
19import com.fs.starfarer.api.util.Misc;
20
21public class NeuralInterface extends BaseHullMod {
22
23 public static float SYSTEM_RESET_TIMEOUT_MULT = 2f;
24 //public static float SYSTEM_RESET_TIMEOUT = 20f;
25 public static final String SYSTEM_RESET_TIMEOUT_KEY = "neural_interface_reset_timeout";
26
27 @Override
28 public void advanceInCombat(ShipAPI ship, float amount) {
29 String key = SYSTEM_RESET_TIMEOUT_KEY;
30// Float timeout = (Float) Global.getCombatEngine().getCustomData().get(key);
31// if (timeout == null) timeout = 0f;
32//
33// if (ship == Global.getCombatEngine().getPlayerShip()) {
34// timeout -= amount;
35// if (timeout < 0) timeout = 0f;
36// Global.getCombatEngine().getCustomData().put(key, timeout);
37// //System.out.println("NI timeout: " + timeout);
38// }
39
40 Float timeout = (Float) ship.getCustomData().get(key);
41 if (timeout == null) timeout = 0f;
42 timeout -= amount;
43 if (timeout < 0) timeout = 0f;
44 ship.setCustomData(key, timeout);
45 //System.out.println("NI timeout: " + timeout);
46
47 if (ship == Global.getCombatEngine().getPlayerShip()) {
49 ShipSystemAPI system = ship.getSystem();
50 if (system != null && timeout <= 0) {
51 boolean didSomething = false;
52 //float maxTimeout = 5f;
53 float maxTimeout = 0f;
54 if (system.getCooldownRemaining() > 0f && system.isCoolingDown()) {
55 maxTimeout = Math.max(system.getCooldownRemaining(), maxTimeout);
56 system.setCooldownRemaining(0);
57 didSomething = true;
58 }
59 if (system.getAmmo() < system.getMaxAmmo() && system.getAmmoPerSecond() > 0) {
60 system.setAmmo(system.getAmmo() + 1);
61 didSomething = true;
62 maxTimeout = Math.max(1f / system.getAmmoPerSecond() * (1f - system.getAmmoReloadProgress()), maxTimeout);
63 }
64 //if (didSomething) {
65 if (maxTimeout > 0) {
66 maxTimeout *= SYSTEM_RESET_TIMEOUT_MULT;
67 //Global.getCombatEngine().getCustomData().put(key, SYSTEM_RESET_TIMEOUT);
68 ship.setCustomData(key, maxTimeout);
69 }
70 }
72 }
73 } else {
75 }
76 }
77
78
79 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
81
83
84 boolean sMod = isSMod(stats);
85 if (sMod) {
87 }
88
89// if (stats.getFleetMember() != null && stats.getFleetMember().getCaptain() != null) {
90// PersonAPI p = stats.getFleetMember().getCaptain();
91// if (p.isDefault() && Misc.isAutomated(stats.getFleetMember())) {
92// p.getMemoryWithoutUpdate().set(AICoreOfficerPluginImpl.AUTOMATED_POINTS_MULT,
93// AICoreOfficerPluginImpl.BETA_MULT);
94// }
95//
96// }
97
98 //stats.getDynamic().getMod(Stats.COORDINATED_MANEUVERS_FLAT).modifyFlat(id, (Float) mag.get(hullSize));
99 //stats.getDynamic().getMod(Stats.COORDINATED_MANEUVERS_FLAT).modifyFlat(id, (Float) mag.get(hullSize));
100 }
101
102 public String getDescriptionParam(int index, HullSize hullSize) {
103 if (this instanceof NeuralIntegrator) {
104 if (index == 0) return "benefit from your combat skills";
105 if (index == 1) return "" + (int)NeuralLinkScript.INSTANT_TRANSFER_DP;
106 if (index == 2) return "" + (int) NeuralIntegrator.DP_INCREASE_PERCENT + "%";
107 }
108 if (index == 0) return "benefit from your combat skills";
109 if (index == 1) return "" + (int)NeuralLinkScript.INSTANT_TRANSFER_DP;
110 return null;
111 }
112
113 @Override
114 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
115 float pad = 3f;
116 float opad = 10f;
117 Color h = Misc.getHighlightColor();
118 Color bad = Misc.getNegativeHighlightColor();
119 Color g = Misc.getGrayColor();
120
121 tooltip.addSectionHeading("Neural system reset", Alignment.MID, opad);
122 tooltip.addPara("After the transfer is complete, the target ship's system cooldown (if any) will be reset, "
123 + "and if the ship system uses charges, it will gain an additonal charge. This effect operates on "
124 + "a cooldown equal to %s the cooldown/charge regeneration time saved by it.", opad, h,
126
127// tooltip.addPara("If installed on an automated ship, increases its "
128// + "\"automated ship points\" value as if a Beta Core was installed on the ship.", opad);
129
132 tooltip.addPara("Requires the Neural Link skill to function", Misc.getNegativeHighlightColor(), opad);
133 }
134 }
135
136 if (isForModSpec || ship == null) return;
137
140 tooltip.addPara("Use the \"" + desc + "\" control [" + control + "] to switch between ships.", opad,
141 g, h, control);
142
143
144 }
145
146 public boolean isApplicableToShip(ShipAPI ship) {
147 if (Misc.isAutomated(ship)) {
148 return false;
149 }
150 if (ship.getHullSpec().getHints().contains(ShipTypeHints.NO_NEURAL_LINK)) {
151 return false;
152 }
153 return true;
154 }
155
156 public String getUnapplicableReason(ShipAPI ship) {
157 if (Misc.isAutomated(ship)) {
158 return "Can not be installed on automated ships, install Neural Integrator instead";
159 }
160 if (ship.getHullSpec().getHints().contains(ShipTypeHints.NO_NEURAL_LINK)) {
161 return "Can not be installed on this ship";
162 }
163 return null;
164 }
165}
166
167
168
169
static SettingsAPI getSettings()
Definition Global.java:57
static CombatEngineAPI getCombatEngine()
Definition Global.java:69
static GameState getCurrentState()
Definition Global.java:27
static SectorAPI getSector()
Definition Global.java:65
boolean isSMod(MutableShipStatsAPI stats)
void modifyFlat(String source, float value)
float computeEffective(float baseValue)
static final String INSTANT_NEURAL_TRANSFER_FROM
Definition Stats.java:21
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
String getDescriptionParam(int index, HullSize hullSize)
static Color getNegativeHighlightColor()
Definition Misc.java:802
static boolean isAutomated(MutableShipStatsAPI stats)
Definition Misc.java:5491
static Color getGrayColor()
Definition Misc.java:826
static Color getHighlightColor()
Definition Misc.java:792
String getControlDescriptionForEnumName(String name)
String getControlStringForEnumName(String name)
MutableCharacterStatsAPI getPlayerStats()
void setCustomData(String key, Object data)
EnumSet< ShipTypeHints > getHints()
void setCooldownRemaining(float remaining)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
LabelAPI addSectionHeading(String str, Alignment align, float pad)