Starsector API
Loading...
Searching...
No Matches
CompromisedStructure.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 CompromisedStructure extends BaseHullMod {
10 public static float DEPLOYMENT_COST_MULT = 0.8f;
11
12 public static void modifyCost(HullSize hullSize, MutableShipStatsAPI stats, String id) {
13 stats.getSuppliesToRecover().modifyMult(id, DEPLOYMENT_COST_MULT);
14
15 float effect = stats.getDynamic().getValue(Stats.DMOD_REDUCE_MAINTENANCE, 0);
16 if (effect > 0) {
17 stats.getSuppliesPerMonth().modifyMult(id, DEPLOYMENT_COST_MULT);
18 }
19 }
20 public static String getCostDescParam(int index, int startIndex) {
21 if (index - startIndex == 0) {
22 return "" + (int) Math.round((1f - DEPLOYMENT_COST_MULT) * 100f) + "%";
23 }
24 return null;
25 }
26
27 public static float ARMOR_PENALTY_MULT = 0.8f;
28 public static float HULL_PENALTY_MULT = 0.8f;
29
30 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
31
32 float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
33 float armorMult = ARMOR_PENALTY_MULT + (1f - ARMOR_PENALTY_MULT) * (1f - effect);
34 float hullMult = HULL_PENALTY_MULT + (1f - HULL_PENALTY_MULT) * (1f - effect);
35
36 stats.getArmorBonus().modifyMult(id, armorMult);
37 stats.getHullBonus().modifyMult(id, hullMult);
38 modifyCost(hullSize, stats, id);
39 }
40
41 public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
42 float effect = 1f;
43 if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
44
45 float armorMult = ARMOR_PENALTY_MULT + (1f - ARMOR_PENALTY_MULT) * (1f - effect);
46 float hullMult = HULL_PENALTY_MULT + (1f - HULL_PENALTY_MULT) * (1f - effect);
47
48 if (index == 0) return "" + (int) Math.round((1f - armorMult) * 100f) + "%";
49 if (index == 1) return "" + (int) Math.round((1f - hullMult) * 100f) + "%";
50 if (index >= 2) return getCostDescParam(index, 2);
51 return null;
52 }
53
54
55}
56
57
58
59
static String getCostDescParam(int index, int startIndex)
static void modifyCost(HullSize hullSize, MutableShipStatsAPI stats, String id)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship)