Starsector API
Loading...
Searching...
No Matches
CarrierGroup.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import com.fs.starfarer.api.campaign.FleetDataAPI;
4import com.fs.starfarer.api.characters.FleetTotalItem;
5import com.fs.starfarer.api.characters.FleetTotalSource;
6import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
7import com.fs.starfarer.api.characters.ShipSkillEffect;
8import com.fs.starfarer.api.characters.SkillSpecAPI;
9import com.fs.starfarer.api.combat.MutableShipStatsAPI;
10import com.fs.starfarer.api.combat.ShipAPI;
11import com.fs.starfarer.api.combat.ShipAPI.HullSize;
12import com.fs.starfarer.api.fleet.FleetMemberAPI;
13import com.fs.starfarer.api.impl.campaign.ids.Strings;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16
17public class CarrierGroup {
18
19 public static float TOP_SPEED_PERCENT = 10;
20 public static float REPLACEMENT_RATE_PERCENT = 50;
21
22 public static float OFFICER_MULT = 1.5f;
23 public static boolean isOfficer(MutableShipStatsAPI stats) {
24 if (stats.getEntity() instanceof ShipAPI) {
25 ShipAPI ship = (ShipAPI) stats.getEntity();
26 if (ship == null) return false;
27 return !ship.getCaptain().isDefault();
28 } else {
29 FleetMemberAPI member = stats.getFleetMember();
30 if (member == null) return false;
31 return !member.getCaptain().isDefault();
32 }
33 }
34 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
35
36 public FleetTotalItem getFleetTotalItem() {
37 return getFighterBaysTotal();
38 }
39
40 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
41 if (hasFighterBays(stats)) {
42 float rateBonus = computeAndCacheThresholdBonus(stats, "cg_rep_rate", REPLACEMENT_RATE_PERCENT, ThresholdBonusType.FIGHTER_BAYS);
43 if (isOfficer(stats)) rateBonus *= OFFICER_MULT;
44 float timeMult = 1f / ((100f + rateBonus) / 100f);
45 stats.getFighterRefitTimeMult().modifyMult(id, timeMult);
46
47 float speedBonus = computeAndCacheThresholdBonus(stats, "cg_top_speed", TOP_SPEED_PERCENT, ThresholdBonusType.FIGHTER_BAYS);
48 if (isOfficer(stats)) speedBonus *= OFFICER_MULT;
49 stats.getMaxSpeed().modifyPercent(id, speedBonus);
50 }
51// else {
52// // may be needed to make refit screen show the right values when adding/removing Converted Hangar
53// // leaving this be for now
54// stats.getFighterRefitTimeMult().unmodifyMult(id);
55// stats.getMaxSpeed().unmodifyPercent(id);
56// }
57 }
58
59 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
60 stats.getFighterRefitTimeMult().unmodifyMult(id);
61 }
62
63 public String getEffectDescription(float level) {
64 return null;
65 }
66
67 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
68 TooltipMakerAPI info, float width) {
69 init(stats, skill);
70
71 FleetDataAPI data = getFleetData(null);
72 float rateBonus = computeAndCacheThresholdBonus(data, stats, "cg_rep_rate", REPLACEMENT_RATE_PERCENT, ThresholdBonusType.FIGHTER_BAYS);
73
74 info.addPara("+%s faster fighter replacement rate (maximum: %s)", 0f, hc, hc,
75 "" + (int) rateBonus + "%",
76 "" + (int) REPLACEMENT_RATE_PERCENT + "%");
77
78 float speedBonus = computeAndCacheThresholdBonus(data, stats, "cg_top_speed", TOP_SPEED_PERCENT, ThresholdBonusType.FIGHTER_BAYS);
79
80 info.addPara("+%s ship top speed (maximum: %s)", 0f, hc, hc,
81 "" + (int) speedBonus + "%",
82 "" + (int) TOP_SPEED_PERCENT + "%");
83
85 info.addPara(indent + "Effect increased by %s for ships with officers, including flagship",
86 0f, tc, hc,
87 "" + Misc.getRoundedValueMaxOneAfterDecimal(OFFICER_MULT) + Strings.X);
88 }
89
90 public ScopeDescription getScopeDescription() {
91 return ScopeDescription.ALL_CARRIERS;
92 }
93
94 }
95
96
97
98}
99
100
101
102
103
void modifyPercent(String source, float value)
void modifyMult(String source, float value)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)
static boolean isOfficer(MutableShipStatsAPI stats)