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) {
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 float opad = 10f;
39 if (ship == null || ship.getHullSpec().hasTag(Tags.AUTOMATED_RECOVERABLE)) {
40 tooltip.addPara("Automated ships usually require specialized equipment and expertise to maintain, "
41 + "resulting in a maximum combat readiness penalty of %s. "
42 + "This penalty can be offset by a fleet commander skilled in the use of "
43 + "automated ships.", opad, Misc.getHighlightColor(),
44 "" + (int)Math.round(MAX_CR_PENALTY * 100f) + "%");
45 }
46
47 if (isInPlayerFleet(ship)) {
48 boolean noPenalty = isAutomatedNoPenalty(ship);
49// String usually = "";
50// if (noPenalty) usually = "usually ";
51 if (noPenalty) {
52 tooltip.addPara("However, this ship was automated in a fashion that does not require special expertise "
53 + "to maintain. Some of the techniques used are poorly understood, likely dating to "
54 + "an earlier period.", opad, Misc.getHighlightColor(),
55 "does not require special expertise");
56 }
57 }
58 }
59
60 public static boolean isAutomatedNoPenalty(MutableShipStatsAPI stats) {
61 if (stats == null) return false;
62 FleetMemberAPI member = stats.getFleetMember();
63 if (member == null) return false;
66 }
67
68 public static boolean isAutomatedNoPenalty(ShipAPI ship) {
69 if (ship == null) return false;
70 FleetMemberAPI member = ship.getFleetMember();
71 if (member == null) return false;
74 }
75
76 public static boolean isAutomatedNoPenalty(FleetMemberAPI member) {
77 if (member == null) return false;
80 }
81
82
83// @Override
84// public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
85// new RoilingSwarmEffect(fighter);
86// }
87
88
89}
boolean isInPlayerFleet(MutableShipStatsAPI stats)
void modifyFlat(String source, float value)
void modifyMult(String source, float value)
static final String AUTOMATED_RECOVERABLE
Definition Tags.java:114
static final String TAG_AUTOMATED_NO_PENALTY
Definition Tags.java:13
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)
static Color getHighlightColor()
Definition Misc.java:792
void setInvalidTransferCommandTarget(boolean invalidTransferCommandTarget)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)