1package com.fs.starfarer.api.impl.hullmods;
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.combat.BaseHullMod;
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.combat.WeaponAPI;
11import com.fs.starfarer.api.combat.WeaponAPI.AIHints;
12import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
13import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
14import com.fs.starfarer.api.combat.listeners.WeaponBaseRangeModifier;
15import com.fs.starfarer.api.loading.WeaponSlotAPI;
16import com.fs.starfarer.api.ui.Alignment;
17import com.fs.starfarer.api.ui.TooltipMakerAPI;
18import com.fs.starfarer.api.util.Misc;
38 if (ship ==
null)
return null;
39 WeaponSize largest =
null;
41 if (slot.isDecorative() )
continue;
42 if (slot.getWeaponType() == WeaponType.BALLISTIC) {
43 if (largest ==
null || largest.ordinal() < slot.getSlotSize().ordinal()) {
44 largest = slot.getSlotSize();
54 if (largest ==
null)
return;
74 ship.
addListener(
new RangefinderRangeModifier(small, medium, max));
78 public float small, medium, max;
79 public RangefinderRangeModifier(
float small,
float medium,
float max) {
91 public float getWeaponBaseRangeFlatMod(ShipAPI ship, WeaponAPI weapon) {
95 if (weapon.getSpec() ==
null) {
98 if (weapon.getSpec().getMountType() != WeaponType.BALLISTIC &&
99 weapon.getSpec().getMountType() != WeaponType.HYBRID) {
102 if (weapon.hasAIHint(AIHints.PD)) {
107 if (weapon.getSize() == WeaponSize.SMALL) {
109 }
else if (weapon.getSize() == WeaponSize.MEDIUM) {
112 if (weapon.getSpec().getMountType() == WeaponType.HYBRID) {
118 if (bonus == 0f)
return 0f;
120 float base = weapon.getSpec().getMaxRange();
121 if (base + bonus > max) {
124 if (bonus < 0) bonus = 0;
201 tooltip.
addPara(
"Utilizes targeting data from the ship's largest ballistic slot "
202 +
"to benefit certain weapons, extending the base range of "
203 +
"typical ballistic weapons to match similar but larger weapons. "
204 +
"Greatly benefits hybrid weapons. Point-defense weapons are unaffected.",
205 opad, h,
"ship's largest ballistic slot",
"base range",
"Greatly benefits hybrid weapons");
208 tooltip.
addPara(
"The range bonus is based on the size of the largest ballistic slot, "
209 +
"and the increased base range is capped, but still subject to other modifiers.", opad);
219 tooltip.
addPara(
"Affects small and medium ballistic weapons.", opad);
222 float colW = (int) ((width - col1W - 12f) / 3f);
227 new Object [] {
"Largest b. slot", col1W,
"Small wpn", colW,
"Medium wpn", colW,
"Range cap", lastW});
235 if (largest == WeaponSize.SMALL) c = h;
236 else if (largest == WeaponSize.MEDIUM) c = h;
245 if (largest == WeaponSize.LARGE) c = h;
257 tooltip.
addPara(
"Affects hybrid weapons (those that can fit into both ballistic and energy slots)"
258 +
" of all sizes.", opad);
261 colW = (int) ((width - col1W - lastW - 15f) / 3f);
265 new Object [] {
"Largest b. slot", col1W,
"Small", colW,
"Medium", colW,
"Large", colW,
"Range cap", lastW});
269 if (largest == WeaponSize.SMALL) c = h;
270 else if (largest == WeaponSize.MEDIUM) c = h;
278 if (largest == WeaponSize.LARGE) c = h;
290 tooltip.
addPara(
"Since the base range is increased, this modifier"
291 +
" - unlike most other flat modifiers - "
292 +
"is increased by percentage modifiers from other hullmods and skills.", opad);
302 if (ship !=
null && largest ==
null) {
310 if (ship !=
null && largest ==
null) {
311 return "Ship has no ballistic weapon slots";
317 return "Can only be installed on destroyer-class hulls and larger";
static boolean CODEX_TOOLTIP_MODE
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
static float BONUS_MEDIUM_3
static float BONUS_SMALL_3
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
boolean isApplicableToShip(ShipAPI ship)
static float BONUS_SMALL_2
String getUnapplicableReason(ShipAPI ship)
static float HYBRID_BONUS_MIN
boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec)
void applyEffectsAfterShipCreation(ShipAPI ship, String id)
static float BONUS_SMALL_1
static WeaponSize getLargestBallisticSlot(ShipAPI ship)
String getDescriptionParam(int index, HullSize hullSize)
static Color getTextColor()
static Color getNegativeHighlightColor()
static Color getBasePlayerColor()
static Color getGrayColor()
static Color getBrightPlayerColor()
static Color getHighlightColor()
static Color getDarkPlayerColor()
ShipHullSpecAPI getHullSpec()
void addListener(Object listener)
List< WeaponSlotAPI > getAllWeaponSlotsCopy()