Starsector API
Loading...
Searching...
No Matches
ShieldShunt.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.ShieldAPI.ShieldType;
6import com.fs.starfarer.api.combat.ShipAPI;
7import com.fs.starfarer.api.combat.ShipAPI.HullSize;
8import com.fs.starfarer.api.impl.campaign.ids.HullMods;
9
10public class ShieldShunt extends BaseHullMod {
11
12 //public static float EMP_RESISTANCE = 50f;
13 //public static float VENT_RATE_BONUS = 50f;
14 public static float ARMOR_BONUS = 15f;
15 public static float SMOD_ARMOR_BONUS = 15f;
16
17
18 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
19 boolean sMod = isSMod(stats);
20
21 //stats.getVentRateMult().modifyPercent(id, VENT_RATE_BONUS);
22 stats.getArmorBonus().modifyPercent(id, ARMOR_BONUS + (sMod ? SMOD_ARMOR_BONUS : 0));
23 //stats.getEmpDamageTakenMult().modifyMult(id, 1f - EMP_RESISTANCE * 0.01f);
24 }
25
26 @Override
27 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
28 ship.setShield(ShieldType.NONE, 0f, 1f, 1f);
29 }
30
31
32 public String getDescriptionParam(int index, HullSize hullSize) {
33 //if (index == 0) return "" + (int) EMP_RESISTANCE + "%";
34 //if (index == 0) return "" + (int) VENT_RATE_BONUS + "%";
35 if (index == 0) return "" + (int) ARMOR_BONUS + "%";
36 return null;
37 }
38
39 public boolean isApplicableToShip(ShipAPI ship) {
40 if (ship.getVariant().getHullSpec().getShieldType() == ShieldType.NONE &&
41 !ship.getVariant().hasHullMod("frontshield")) return false;
42 if (ship.getVariant().hasHullMod(HullMods.SHIELD_SHUNT)) return true;
43 if (ship.getVariant().hasHullMod(HullMods.MAKESHIFT_GENERATOR)) return false;
44 return ship != null && ship.getShield() != null;
45 }
46
47 public String getUnapplicableReason(ShipAPI ship) {
49 return "Incompatible with Makeshift Shield Generator";
50 }
51 return "Ship has no shields";
52 }
53
54 public String getSModDescriptionParam(int index, HullSize hullSize) {
55 if (index == 0) return "" + (int) SMOD_ARMOR_BONUS + "%";
56 return null;
57 }
58
59 public boolean hasSModEffect() {
60 // breaks something if it can be built in - I think something to do with preconditions for
61 // shield-related hullmods; not 100% sure on details but sure there was a problem -am
62 // Ah! The issue was being able to build it in and then some kind of order-of-operations with
63 // Makeshift Shield Generator. Made those incompatible. -am
64 return true;
65 }
66
67}
68
69
70
71
72
73
74
75
76
boolean isSMod(MutableShipStatsAPI stats)
void modifyPercent(String source, float value)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
void applyEffectsAfterShipCreation(ShipAPI ship, String id)
String getDescriptionParam(int index, HullSize hullSize)
String getSModDescriptionParam(int index, HullSize hullSize)
void setShield(ShieldType type, float shieldUpkeep, float shieldEfficiency, float arc)