1package com.fs.starfarer.api.impl.campaign.abilities;
3import java.util.ArrayList;
8import org.lwjgl.util.vector.Vector2f;
10import com.fs.starfarer.api.EveryFrameScript;
11import com.fs.starfarer.api.Global;
12import com.fs.starfarer.api.campaign.BattleAPI;
13import com.fs.starfarer.api.campaign.CampaignFleetAPI;
14import com.fs.starfarer.api.campaign.JumpPointAPI.JumpDestination;
15import com.fs.starfarer.api.campaign.NascentGravityWellAPI;
16import com.fs.starfarer.api.campaign.SectorEntityToken;
17import com.fs.starfarer.api.campaign.StarSystemAPI;
18import com.fs.starfarer.api.campaign.econ.MarketAPI;
19import com.fs.starfarer.api.fleet.FleetMemberAPI;
20import com.fs.starfarer.api.impl.campaign.ids.Pings;
21import com.fs.starfarer.api.impl.campaign.ids.Stats;
22import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
23import com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionIntel;
24import com.fs.starfarer.api.ui.LabelAPI;
25import com.fs.starfarer.api.ui.TooltipMakerAPI;
26import com.fs.starfarer.api.util.Misc;
27import com.fs.starfarer.api.util.Misc.FleetMemberDamageLevel;
54 if (fleet ==
null)
return;
86 if (fleet ==
null)
return;
91 float acc = Math.max(speed, 200f)/activateSeconds + fleet.
getAcceleration();
92 float ds = acc * amount;
93 if (ds > speed) ds = speed;
101 float dist = Float.MAX_VALUE;
110 JumpDestination dest =
new JumpDestination(token,
null);
115 if (crCostFleetMult > 0) {
118 Misc.
applyDamage(member,
null, FleetMemberDamageLevel.LOW,
false,
null,
null,
119 true,
null, member.getShipName() +
" suffers damage from Transverse Jump activation");
123 float crLoss = member.getDeployCost() *
CR_COST_MULT * crCostFleetMult;
124 member.getRepairTracker().applyCREvent(-crLoss,
"Transverse jump");
126 String key =
"$makeTranverseJumpCostMoreCROnce";
137 float maxInSystem = 20000f;
138 float maxInHyper = 2000f;
139 float f = offset.length() / maxInSystem;
141 if (f > 0.5f) f = 0.5f;
146 destOffset.scale(f * maxInHyper);
148 Vector2f.add(system.
getLocation(), destOffset, destOffset);
151 JumpDestination dest =
new JumpDestination(token,
null);
162 return super.getActivationText();
175 if (fleet ==
null)
return;
180 if (!super.isUsable())
return false;
181 if (
getFleet() ==
null)
return false;
205 if (fleet ==
null)
return null;
208 float minDist = Float.MAX_VALUE;
211 for (Object o : wells) {
215 if (dist > maxDist)
continue;
216 if (dist < minDist) {
228 if (fleet ==
null)
return;
245 tooltip.
addPara(
"Jump into hyperspace without the use of a jump-point, or " +
246 "jump into a star system across the hyperspace boundary near a nascent gravity well, " +
247 "emerging near the entity corresponding to the gravity well.", pad);
251 String years =
"year's";
253 tooltip.
addPara(
"Jumping into hyperspace consumes %s light " + years +
" worth of fuel and reduces the combat readiness "
254 +
"of all ships by %s of a combat deployment. " +
255 "Jumping into a star system is free.", pad,
260 tooltip.
addPara(
"Ships with insufficient combat readiness may suffer damage when the ability is activated.", pad);
265 if (supplyCost > 0) {
266 tooltip.
addPara(
"Jumping into hyperspace consumes %s fuel and slightly reduces the combat readiness" +
267 " of all ships, costing up to %s supplies to recover. Jumping into a star system is free.", pad,
272 tooltip.
addPara(
"Jumping into hyperspace consumes %s fuel. Jumping into a star system is free.", pad,
279 tooltip.
addPara(
"Can not be used right now.", bad, pad);
284 tooltip.
addPara(
"Not enough fuel.", bad, pad);
288 if (!nonReady.isEmpty()) {
290 tooltip.
addPara(
"Some ships don't have enough combat readiness to safely initiate a transverse jump " +
291 "and may suffer damage if the ability is activated:", pad,
298 if (nonReady.size() > max + 1) {
304 if (!member.isFighterWing()) {
305 str += member.getShipName() +
", ";
306 str += member.getHullSpec().getHullNameWithDashClass();
308 str += member.getVariant().getFullDesignationWithHullName();
348 tooltip.
addPara(
"Must be near a nascent gravity well.", bad, pad);
362 if (engagedInHostilities) {
374 List<FleetMemberAPI> result =
new ArrayList<FleetMemberAPI>();
376 if (fleet ==
null)
return result;
383 float crLoss = member.getDeployCost() *
CR_COST_MULT * crCostFleetMult;
384 if (Math.round(member.getRepairTracker().getCR() * 100) < Math.round(crLoss * 100)) {
393 if (fleet ==
null)
return 0f;
401 String key =
"$makeTranverseJumpCostMoreCROnce";
403 crCostFleetMult = 20f;
405 return crCostFleetMult;
410 if (fleet ==
null)
return 0f;
418 cost += member.getDeploymentCostSupplies() *
CR_COST_MULT * crCostFleetMult;
443 return super.getCooldownFraction();
447 return super.showCooldownIndicator();
451 return super.getCooldownFraction() < 1f;
460 return super.getCooldownColor();
static SettingsAPI getSettings()
static boolean CODEX_TOOLTIP_MODE
static SectorAPI getSector()
boolean isActiveOrInProgress()
CampaignFleetAPI getFleet()
float getActivationDays()
void addIncompatibleToTooltip(TooltipMakerAPI tooltip, boolean expanded)
static float ACTIVATION_DAMAGE_PROB
static float NASCENT_JUMP_DIST
String getActivationText()
boolean showCooldownIndicator()
void applyEffect(float amount, float level)
void fleetOpenedMarket(MarketAPI market)
static float CR_COST_MULT
NascentGravityWellAPI well
float computeSupplyCost()
boolean canUseToJumpToSystem()
float getCRCostMult(CampaignFleetAPI fleet)
boolean isCooldownRenderingAdditive()
boolean canUseToJumpToHyper()
static float FUEL_USE_MULT
void createTooltip(TooltipMakerAPI tooltip, boolean expanded)
float getCooldownFraction()
NascentGravityWellAPI getNearestWell(float maxDist)
List< FleetMemberAPI > getNonReadyShips()
void fleetLeftBattle(BattleAPI battle, boolean engagedInHostilities)
static final String TRANSVERSE_JUMP
static final String DIRECT_JUMP_CR_MULT
static final String INDENT
static boolean isTutorialInProgress()
static Vector2f getUnitVectorAtDegreeAngle(float degrees)
static Color getNegativeHighlightColor()
static Color getGrayColor()
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static void applyDamage(FleetMemberAPI member, Random random, FleetMemberDamageLevel level, boolean withCRDamage, String crDamageId, String crDamageReason, boolean withMessage, TextPanelAPI textPanel, String messageText)
static Color scaleAlpha(Color color, float factor)
static Color getHighlightColor()
static Vector2f getPointAtRadius(Vector2f from, float r)
static float getAngleInDegreesStrict(Vector2f v)
static String getRoundedValueMaxOneAfterDecimal(float value)
static float getAngleInDegrees(Vector2f v)
static String getRoundedValue(float value)
Color getColor(String id)
LocationAPI getContainingLocation()
void setVelocity(float x, float y)
FleetDataAPI getFleetData()
MutableFleetStatsAPI getStats()
FleetLogisticsAPI getLogistics()
boolean isInHyperspaceTransition()
FaderUtil getSharedFader()
void removeFuel(float quantity)
List< FleetMemberAPI > getMembersListCopy()
List getEntities(Class implementedClassOrInterface)
SectorEntityToken createToken(float x, float y)
SectorEntityToken getTarget()
CampaignClockAPI getClock()
void doHyperspaceTransition(CampaignFleetAPI fleet, SectorEntityToken jumpLocation, JumpDestination dest)
EveryFrameScript addPing(SectorEntityToken entity, String pingType)
void removeScript(EveryFrameScript script)
CampaignUIAPI getCampaignUI()
LocationAPI getHyperspace()
LocationAPI getContainingLocation()
MemoryAPI getMemoryWithoutUpdate()
SectorEntityToken getCenter()
boolean contains(String key)
float getFuelCostPerLightYear()
DynamicStatsAPI getDynamic()
float getValue(String id)