Starsector API
All Classes Namespaces Files Functions Variables
BDeck.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import com.fs.starfarer.api.GameState;
4import com.fs.starfarer.api.Global;
5import com.fs.starfarer.api.combat.BaseHullMod;
6import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
7import com.fs.starfarer.api.combat.MutableShipStatsAPI;
8import com.fs.starfarer.api.combat.ShipAPI;
9import com.fs.starfarer.api.combat.ShipAPI.HullSize;
10import com.fs.starfarer.api.combat.listeners.AdvanceableListener;
11import com.fs.starfarer.api.loading.FighterWingSpecAPI;
12
13public class BDeck extends BaseHullMod {
14
15 public static float REPLACEMENT_RATE_THRESHOLD = 0.4f;
16 public static float REPLACEMENT_RATE_RESET = 1f;
17 public static float CR_COST_MULT = 0f;
18
19
20
21 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
22
23 }
24
25 @Override
26 public void advanceInCombat(ShipAPI ship, float amount) {
27 super.advanceInCombat(ship, amount);
28 }
29
30 @Override
31 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
32 ship.addListener(new BDeckListener(ship));
33 }
34
35 public static Object STATUS_KEY = new Object();
36
37 public static class BDeckListener implements AdvanceableListener {
38 protected ShipAPI ship;
39 protected boolean fired = false;
40 public BDeckListener(ShipAPI ship) {
41 this.ship = ship;
42 }
43
44 public void advance(float amount) {
45 float cr = ship.getCurrentCR();
46 float crCost = ship.getDeployCost() * CR_COST_MULT;
47
48 if (!fired && cr >= crCost) {
49 if (ship.getSharedFighterReplacementRate() <= REPLACEMENT_RATE_THRESHOLD) {
50 fired = true;
51
52 for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
53 if (bay.getWing() == null) continue;
54
55 float rate = REPLACEMENT_RATE_RESET;
56 bay.setCurrRate(rate);
57
58 bay.makeCurrentIntervalFast();
59 FighterWingSpecAPI spec = bay.getWing().getSpec();
60
61 int maxTotal = spec.getNumFighters();
62 int actualAdd = maxTotal - bay.getWing().getWingMembers().size();
63 if (actualAdd > 0) {
64 bay.setFastReplacements(bay.getFastReplacements() + actualAdd);
65// bay.setExtraDeployments(actualAdd);
66// bay.setExtraDeploymentLimit(maxTotal);
67// bay.setExtraDuration(EXTRA_FIGHTER_DURATION);
68 }
69
70 if (crCost > 0) {
71 ship.setCurrentCR(ship.getCurrentCR() - crCost);
72 }
73 }
74 }
75 }
76
77 if (Global.getCurrentState() == GameState.COMBAT &&
78 Global.getCombatEngine() != null && Global.getCombatEngine().getPlayerShip() == ship) {
79
80 String status = "ON STANDBY";
81 boolean penalty = false;
82 if (fired) status = "OPERATIONAL";
83 if (!fired && cr < crCost) {
84 status = "NOT READY";
85 penalty = true;
86 }
87 Global.getCombatEngine().maintainStatusForPlayerShip(STATUS_KEY,
88 Global.getSettings().getSpriteName("ui", "icon_tactical_bdeck"),
89 "B-DECK", status, penalty);
90 }
91 }
92
93 }
94
95
96 public String getDescriptionParam(int index, HullSize hullSize) {
97 if (index == 0) {
98 return (int) Math.round(REPLACEMENT_RATE_THRESHOLD * 100f) + "%";
99 }
100 if (index == 1) {
101 return (int) Math.round(REPLACEMENT_RATE_RESET * 100f) + "%";
102 }
103 return null;
104 }
105//
106// @Override
107// public boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec) {
108// return false;
109// }
110//
111// @Override
112// public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
113// float pad = 3f;
114// float opad = 10f;
115// Color h = Misc.getHighlightColor();
116// Color bad = Misc.getNegativeHighlightColor();
117//
118//
119// if (!Misc.isAutomated(ship)) {
120// tooltip.addPara("Originally designed by the Tri-Tachyon Corporation for use on its combat droneships, "
121// + "the coherence field strengh has to be dialed down to allow operation on crewed vessels.", opad);
122// tooltip.addPara("Increases the base range of all non-beam Energy and Hybrid weapons by %s.", opad, h,
123// "" + (int)CREWED_RANGE_BONUS);
124// tooltip.addPara("The coherence field is unstable under combat conditions, with stresses on the hull "
125// + "resulting in spot failures that release bursts of lethal radiation. "
126// + "Crew casualties in combat are increased by %s.", opad, h,
127// "" + (int) CREW_CASUALTIES + "%");
128// } else {
129// tooltip.addPara("Increases the base range of all non-beam Energy and Hybrid weapons by %s.", opad, h,
130// "" + (int)RANGE_BONUS);
131// }
132//
133// tooltip.addSectionHeading("Interactions with other modifiers", Alignment.MID, opad);
134// tooltip.addPara("Since the base range is increased, this range modifier"
135// + " - unlike most other flat modifiers in the game - "
136// + "is increased by percentage modifiers from other hullmods and skills.", opad);
137// }
138//
153
154}
155
156
157
158
159
160
161
162
163
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
Definition BDeck.java:21
void advanceInCombat(ShipAPI ship, float amount)
Definition BDeck.java:26
void applyEffectsAfterShipCreation(ShipAPI ship, String id)
Definition BDeck.java:31
String getDescriptionParam(int index, HullSize hullSize)
Definition BDeck.java:96