Starsector API
Loading...
Searching...
No Matches
FragileSubsystems.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import com.fs.starfarer.api.combat.BaseHullMod;
4import com.fs.starfarer.api.combat.MutableShipStatsAPI;
5import com.fs.starfarer.api.combat.ShipAPI;
6import com.fs.starfarer.api.combat.ShipAPI.HullSize;
7import com.fs.starfarer.api.impl.campaign.ids.Stats;
8
9public class FragileSubsystems extends BaseHullMod {
10
11 public static final float PEAK_PENALTY_PERCENT = 30f;
12 public static final float DEGRADE_INCREASE_PERCENT = 30f;
13
14
15 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
16 float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
17
18 stats.getPeakCRDuration().modifyMult(id, 1f - (PEAK_PENALTY_PERCENT * effect) / 100f);
20 CompromisedStructure.modifyCost(hullSize, stats, id);
21 }
22
23 public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
24 float effect = 1f;
25 if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
26
27 if (index == 0) return "" + (int) Math.round(PEAK_PENALTY_PERCENT * effect) + "%";
28 if (index == 1) return "" + (int) Math.round(DEGRADE_INCREASE_PERCENT * effect) + "%";
29 if (index >= 2) return CompromisedStructure.getCostDescParam(index, 2);
30 return null;
31 }
32
33 public boolean isApplicableToShip(ShipAPI ship) {
34 return ship != null && (ship.getHullSpec().getNoCRLossTime() < 10000 || ship.getHullSpec().getCRLossPerSecond(ship.getMutableStats()) > 0);
35 }
36
37 public String getUnapplicableReason(ShipAPI ship) {
38 return "Ship does not suffer from CR degradation";
39 }
40}
41
42
43
44
void modifyMult(String source, float value)
void modifyPercent(String source, float value)
static String getCostDescParam(int index, int startIndex)
static void modifyCost(HullSize hullSize, MutableShipStatsAPI stats, String id)
String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
MutableShipStatsAPI getMutableStats()