Starsector API
Loading...
Searching...
No Matches
Automated.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.fleet.FleetMemberAPI;
8import com.fs.starfarer.api.impl.campaign.ids.Tags;
9import com.fs.starfarer.api.ui.TooltipMakerAPI;
10import com.fs.starfarer.api.util.Misc;
11
12public class Automated extends BaseHullMod {
13
14 public static float MAX_CR_PENALTY = 1f;
15
16 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
17 stats.getMinCrewMod().modifyMult(id, 0);
18 stats.getMaxCrewMod().modifyMult(id, 0);
19
20 if (isInPlayerFleet(stats) && !isAutomatedNoPenalty(stats)) {
21 stats.getMaxCombatReadiness().modifyFlat(id, -MAX_CR_PENALTY, "Automated ship penalty");
22 }
23 }
24
25 @Override
26 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
27 ship.setInvalidTransferCommandTarget(true);
28 }
29
30
31
32 public String getDescriptionParam(int index, HullSize hullSize) {
33 if (index == 0) return "" + (int)Math.round(MAX_CR_PENALTY * 100f) + "%";
34 return null;
35 }
36
37 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
38 if (isInPlayerFleet(ship)) {
39 float opad = 10f;
40 boolean noPenalty = isAutomatedNoPenalty(ship);
41 String usually = "";
42 if (noPenalty) usually = "usually ";
43// tooltip.addPara("Automated ships " + usually + "require specialized equipment and expertise to maintain. In a " +
44// "fleet lacking these, they're virtually useless, with their maximum combat " +
45// "readiness being reduced by %s.", opad, Misc.getHighlightColor(),
46// "" + (int)Math.round(MAX_CR_PENALTY * 100f) + "%");
47 if (noPenalty) {
48 tooltip.addPara("However, this ship was automated in a fashion that does not require special expertise "
49 + "to maintain. Some of the techniques used are poorly understood, likely dating to "
50 + "an earlier period.", opad, Misc.getHighlightColor(),
51 "does not require special expertise");
52 }
53 }
54 }
55
56 public static boolean isAutomatedNoPenalty(MutableShipStatsAPI stats) {
57 if (stats == null) return false;
58 FleetMemberAPI member = stats.getFleetMember();
59 if (member == null) return false;
60 return member.getHullSpec().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY) ||
61 member.getVariant().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY);
62 }
63
64 public static boolean isAutomatedNoPenalty(ShipAPI ship) {
65 if (ship == null) return false;
66 FleetMemberAPI member = ship.getFleetMember();
67 if (member == null) return false;
68 return member.getHullSpec().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY) ||
69 member.getVariant().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY);
70 }
71
72 public static boolean isAutomatedNoPenalty(FleetMemberAPI member) {
73 if (member == null) return false;
74 return member.getHullSpec().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY) ||
75 member.getVariant().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY);
76 }
77
78}
void applyEffectsAfterShipCreation(ShipAPI ship, String id)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
static boolean isAutomatedNoPenalty(FleetMemberAPI member)
static boolean isAutomatedNoPenalty(MutableShipStatsAPI stats)
static boolean isAutomatedNoPenalty(ShipAPI ship)
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
String getDescriptionParam(int index, HullSize hullSize)