Starsector API
Loading...
Searching...
No Matches
MilitarizedSubsystems.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.characters.MutableCharacterStatsAPI;
6import com.fs.starfarer.api.characters.PersonAPI;
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.fleet.FleetMemberAPI;
11import com.fs.starfarer.api.impl.campaign.ids.HullMods;
12import com.fs.starfarer.api.impl.campaign.ids.Stats;
13
15
16 private static int BURN_LEVEL_BONUS = 1;
17 private static float MAINTENANCE_PERCENT = 100;
18// private static float FLUX_PERCENT = 25;
19// private static float ARMOR_BONUS = 25;
20// private static float FLUX_DISSIPATION_PERCENT = 10;
21// private static float ARMOR_BONUS = 10;
22
23 //private static final float DEPLOY_COST_MULT = 0.7f;
24
25 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
26 boolean sMod = isSMod(stats);
27
28 stats.getSensorStrength().unmodify(HullMods.CIVGRADE);
29 stats.getSensorProfile().unmodify(HullMods.CIVGRADE);
30
31 stats.getMaxBurnLevel().modifyFlat(id, BURN_LEVEL_BONUS);
32
33// float mult = getEffectMult(stats);
34// stats.getFluxDissipation().modifyPercent(id, FLUX_DISSIPATION_PERCENT * mult);
35// stats.getEffectiveArmorBonus().modifyFlat(id, ARMOR_BONUS * mult);
36
37 //stats.getSuppliesPerMonth().modifyPercent(id, MAINTENANCE_PERCENT);
38 if (!sMod) {
39 stats.getMinCrewMod().modifyPercent(id, MAINTENANCE_PERCENT);
40 }
41
42 //stats.getDynamic().getMod(Stats.ACT_AS_COMBAT_SHIP).modifyFlat(id, 1f);
43
44 }
45
46 public static float getEffectMult(MutableShipStatsAPI stats) {
47 float bonus = getBonusPercent(stats);
48 return 1f + bonus / 100f;
49 }
50 //public static float getBonusPercent(ShipAPI ship) {
51 public static float getBonusPercent(MutableShipStatsAPI stats) {
52 if (Global.getSettings().getCurrentState() == GameState.TITLE) return 0f;
53 //FleetMemberAPI member = ship.getFleetMember();
54 MutableCharacterStatsAPI cStats = null;
55 if (stats == null) {
56 cStats = Global.getSector().getPlayerStats();
57 } else {
58 FleetMemberAPI member = stats.getFleetMember();
59 if (member == null) return 0f;
60 PersonAPI commander = member.getFleetCommanderForStats();
61 if (commander == null) {
62 commander = member.getFleetCommander();
63 }
64 if (commander == null) return 0f;
65 cStats = commander.getStats();
66 }
67 float bonus = cStats.getDynamic().getMod(Stats.AUXILIARY_EFFECT_ADD_PERCENT).computeEffective(0f);
68 return Math.round(bonus);
69 }
70
71
72// @Override
73// public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
74// if (ship == null) return;
75// if (Global.getSettings().getCurrentState() == GameState.TITLE) return;
76//
77// float bonus = getBonusPercent(ship);
78// if(bonus <= 0) return;
79//
80// float opad = 10f;
81// tooltip.addSectionHeading("Auxiliary Support", Alignment.MID, opad);
82// }
83
84
85
86 public String getDescriptionParam(int index, HullSize hullSize) {
87 if (index == 0) return "" + BURN_LEVEL_BONUS;
88 //if (index == 1) return "" + (int)Math.round((1f - DEPLOY_COST_MULT) * 100f) + "%";
89// float mult = getEffectMult(null);
90// if (index == 1) return "" + (int) Math.round(FLUX_DISSIPATION_PERCENT * mult) + "%";
91// if (index == 2) return "" + (int) Math.round(ARMOR_BONUS * mult);
92 if (index == 1) return "" + (int)Math.round(MAINTENANCE_PERCENT) + "%";
93 return null;
94 }
95 @Override
96 public boolean isApplicableToShip(ShipAPI ship) {
97 return ship.getVariant().hasHullMod(HullMods.CIVGRADE) && super.isApplicableToShip(ship);
98 }
99
100 @Override
101 public String getUnapplicableReason(ShipAPI ship) {
102 if (!ship.getVariant().hasHullMod(HullMods.CIVGRADE)) {
103 return "Can only be installed on civilian-grade hulls";
104 }
105 return super.getUnapplicableReason(ship);
106 }
107
108
109
110
111}
112
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)