1package com.fs.starfarer.api.impl.hullmods;
4import java.util.HashMap;
7import com.fs.starfarer.api.GameState;
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.CampaignFleetAPI;
10import com.fs.starfarer.api.combat.HullModFleetEffect;
11import com.fs.starfarer.api.combat.MutableShipStatsAPI;
12import com.fs.starfarer.api.combat.ShipAPI;
13import com.fs.starfarer.api.combat.ShipAPI.HullSize;
14import com.fs.starfarer.api.fleet.FleetMemberAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Stats;
16import com.fs.starfarer.api.ui.LabelAPI;
17import com.fs.starfarer.api.ui.TooltipMakerAPI;
18import com.fs.starfarer.api.util.Misc;
20@SuppressWarnings(
"unchecked")
26 public static float MIN_CR = 0.1f;
27 public static String MOD_KEY =
"core_HighResSensors";
29 private static Map combatMag =
new HashMap();
30 private static Map mag =
new HashMap();
38 mag.put(HullSize.FRIGATE, 50f);
39 mag.put(HullSize.DESTROYER, 75f);
40 mag.put(HullSize.CRUISER, 100f);
41 mag.put(HullSize.CAPITAL_SHIP, 150f);
43 combatMag.put(HullSize.FRIGATE, 1000f);
44 combatMag.put(HullSize.DESTROYER, 1500f);
45 combatMag.put(HullSize.CRUISER, 2000f);
46 combatMag.put(HullSize.CAPITAL_SHIP, 2500f);
57 boolean sMod = isSMod(stats);
59 float mag = ((Float) combatMag.get(hullSize)).intValue();
65 if (index == 0)
return "" + ((Float) combatMag.get(HullSize.FRIGATE)).intValue();
66 if (index == 1)
return "" + ((Float) combatMag.get(HullSize.DESTROYER)).intValue();
67 if (index == 2)
return "" + ((Float) combatMag.get(HullSize.CRUISER)).intValue();
68 if (index == 3)
return "" + ((Float) combatMag.get(HullSize.CAPITAL_SHIP)).intValue();
91 float modifier = getAdjustedHRSModifier(fleet,
null, 0f);
111 tooltip.
addPara(
"A ship with high resolution sensors increases the fleet's sensor range by %s/%s/%s/%s," +
112 " depending on hull size. " +
113 "Each additional ship with high resolution sensors provides diminishing returns. " +
114 "The higher the highest sensor range increase from a single ship in the fleet, the later diminishing returns kick in.",
116 "" + ((Float) mag.get(HullSize.FRIGATE)).intValue(),
117 "" + ((Float) mag.get(HullSize.DESTROYER)).intValue(),
118 "" + ((Float) mag.get(HullSize.CRUISER)).intValue(),
119 "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue()
122 if (isForModSpec || ship ==
null)
return;
126 float fleetMod = getAdjustedHRSModifier(fleet,
null, 0f);
127 float currShipMod = (Float) mag.get(hullSize);
129 float fleetModWithOneMore = getAdjustedHRSModifier(fleet,
null, currShipMod);
130 float fleetModWithoutThisShip = getAdjustedHRSModifier(fleet, ship.
getFleetMemberId(), 0f);
132 tooltip.
addPara(
"The total sensor strength increase for your fleet is %s.", opad, h,
133 "" + (
int)Math.round(fleetMod));
138 cr = member.getRepairTracker().getCR();
143 LabelAPI label = tooltip.
addPara(
"This ship's combat readiness is below %s " +
144 "and its high resolution sensors can not be utilized. Bringing this ship into readiness " +
145 "would increase the fleetwide bonus to %s.",
147 "" + (
int) Math.round(MIN_CR * 100f) +
"%",
148 "" + (
int)Math.round(fleetModWithOneMore));
150 label.
setHighlight(
"" + (
int) Math.round(MIN_CR * 100f) +
"%",
"" + (
int)Math.round(fleetModWithOneMore));
152 if (fleetMod > currShipMod) {
153 tooltip.
addPara(
"Removing this ship would decrease it to %s. Adding another ship of the same type " +
154 "would increase it to %s.", opad, h,
155 "" + (
int)Math.round(fleetModWithoutThisShip),
156 "" + (
int)Math.round(fleetModWithOneMore));
158 tooltip.
addPara(
"Adding another ship of the same type " +
159 "would increase it to %s.", opad, h,
160 "" + (
int)Math.round(fleetModWithOneMore));
169 if (member.isMothballed())
continue;
170 if (member.getRepairTracker().getCR() < MIN_CR)
continue;
172 if (member.getId().equals(skipId)) {
176 if (v <= 0)
continue;
178 if (v > max) max = v;
181 if (add > max) max = add;
184 if (max <= 0)
return 0f;
185 float units = total / max;
186 if (units <= 1)
return max;
188 float result = total * mult / units;
192 result = Math.round(result * 100f) / 100f;
193 result = Math.max(result, 1f);
static SettingsAPI getSettings()
static SectorAPI getSector()
void modifyFlat(String source, float value)
void unmodifyFlat(String source)
static final String HRS_SENSOR_RANGE_MOD
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
void onFleetSync(CampaignFleetAPI fleet)
String getDescriptionParam(int index, HullSize hullSize)
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
static float getAdjustedHRSModifier(CampaignFleetAPI fleet, String skipId, float add)
boolean withAdvanceInCampaign()
String getSModDescriptionParam(int index, HullSize hullSize)
boolean withOnFleetSync()
boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec)
void advanceInCampaign(CampaignFleetAPI fleet)
static Color getNegativeHighlightColor()
static Color getHighlightColor()
static float logOfBase(float base, float num)
GameState getCurrentState()
FleetDataAPI getFleetData()
List< FleetMemberAPI > getMembersListCopy()
CampaignFleetAPI getPlayerFleet()
StatBonus getSensorRangeMod()
DynamicStatsAPI getDynamic()
StatBonus getSightRadiusMod()
String getFleetMemberId()
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)
StatBonus getMod(String id)