1package com.fs.starfarer.api.impl.campaign.intel.events.ht;
3import java.util.ArrayList;
4import java.util.EnumSet;
10import org.lwjgl.util.vector.Vector2f;
12import com.fs.starfarer.api.Global;
13import com.fs.starfarer.api.campaign.BattleAPI;
14import com.fs.starfarer.api.campaign.CampaignEventListener.FleetDespawnReason;
15import com.fs.starfarer.api.campaign.CampaignFleetAPI;
16import com.fs.starfarer.api.campaign.CargoAPI;
17import com.fs.starfarer.api.campaign.InteractionDialogAPI;
18import com.fs.starfarer.api.campaign.LocationAPI;
19import com.fs.starfarer.api.campaign.PersistentUIDataAPI.AbilitySlotAPI;
20import com.fs.starfarer.api.campaign.PersistentUIDataAPI.AbilitySlotsAPI;
21import com.fs.starfarer.api.campaign.SectorEntityToken;
22import com.fs.starfarer.api.campaign.SpecialItemData;
23import com.fs.starfarer.api.campaign.StarSystemAPI;
24import com.fs.starfarer.api.campaign.TextPanelAPI;
25import com.fs.starfarer.api.campaign.econ.Industry;
26import com.fs.starfarer.api.campaign.econ.MarketAPI;
27import com.fs.starfarer.api.campaign.listeners.CharacterStatsRefreshListener;
28import com.fs.starfarer.api.campaign.listeners.CurrentLocationChangedListener;
29import com.fs.starfarer.api.campaign.listeners.FleetEventListener;
30import com.fs.starfarer.api.combat.MutableStat;
31import com.fs.starfarer.api.combat.MutableStat.StatMod;
32import com.fs.starfarer.api.combat.StatBonus;
33import com.fs.starfarer.api.impl.campaign.ids.Abilities;
34import com.fs.starfarer.api.impl.campaign.ids.Industries;
35import com.fs.starfarer.api.impl.campaign.ids.Items;
36import com.fs.starfarer.api.impl.campaign.ids.Stats;
37import com.fs.starfarer.api.impl.campaign.ids.Tags;
38import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel;
39import com.fs.starfarer.api.impl.campaign.intel.events.BaseFactorTooltip;
40import com.fs.starfarer.api.impl.campaign.intel.events.EventFactor;
41import com.fs.starfarer.api.impl.campaign.rulecmd.AddAbility;
42import com.fs.starfarer.api.impl.campaign.velfield.SlipstreamTerrainPlugin2;
43import com.fs.starfarer.api.ui.SectorMapAPI;
44import com.fs.starfarer.api.ui.TooltipMakerAPI;
45import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
46import com.fs.starfarer.api.util.Misc;
47import com.fs.starfarer.api.util.Misc.Token;
48import com.fs.starfarer.api.util.Misc.TokenType;
49import com.fs.starfarer.api.util.TimeoutTracker;
80 public static String
KEY =
"$hte_ref";
82 public static enum Stage {
85 SLIPSTREAM_NAVIGATION,
87 HYPERFIELD_OPTIMIZATION,
96 public static class RecentTopographyReadings {
98 public RecentTopographyReadings(Vector2f loc) {
152 getDataFor(Stage.SLIPSTREAM_NAVIGATION).keepIconBrightWhenLaterStageReached =
true;
153 getDataFor(Stage.SLIPSTREAM_DETECTION).keepIconBrightWhenLaterStageReached =
true;
154 getDataFor(Stage.REVERSE_POLARITY).keepIconBrightWhenLaterStageReached =
true;
155 getDataFor(Stage.HYPERFIELD_OPTIMIZATION).keepIconBrightWhenLaterStageReached =
true;
156 getDataFor(Stage.GENERATE_SLIPSURGE).keepIconBrightWhenLaterStageReached =
true;
161 if (
getDataFor(Stage.GENERATE_SLIPSURGE) ==
null) {
170 super.notifyEnding();
180 Color tc,
float initPad) {
189 if (esd.id == Stage.SLIPSTREAM_DETECTION) {
190 info.
addPara(
"Able to detect slipstreams near your spaceports", tc, initPad);
192 if (esd.id == Stage.SLIPSTREAM_NAVIGATION) {
195 info.
addPara(
"Fuel use while traversing slipstreams reduced by %s", initPad, tc,
198 if (esd.id == Stage.HYPERFIELD_OPTIMIZATION) {
199 info.
addPara(
"Maximum burn increased by %s while in hyperspace", initPad, tc,
202 if (esd.id == Stage.REVERSE_POLARITY) {
203 info.
addPara(
"%s ability unlocked", initPad, tc, h,
"Reverse Polarity");
205 if (esd.id == Stage.GENERATE_SLIPSURGE) {
206 info.
addPara(
"%s ability unlocked", initPad, tc, h,
"Generate Slipsurge");
208 if (esd.id == Stage.TOPOGRAPHIC_DATA) {
209 info.
addPara(
"Topographic data gained", tc, initPad);
224 if (stageId == Stage.START) {
233 if (stageId == Stage.START) {
254 if (stage ==
null)
return;
271 if (stageId == Stage.START) {
272 info.
addPara(
"Detailed sensor readings greatly aid hyperspace navigation. "
273 +
"There are many ways of acquiring this data, including using in-system sensor arrays,"
274 +
" using an Active Sensor Burst near interesting phenomena, "
275 +
"traveling through hyperspace at a very high burn level, or simply buying the data from scavengers.",
277 }
else if (stageId == Stage.SLIPSTREAM_DETECTION) {
289 info.
addPara(
"Allows a Spaceport "
290 +
"to detect nearby slipstreams. Detection range increased "
291 +
"for %s. Claimed sensor arrays within %s light-years provide extra detection range: "
292 +
"%s ly for Domain-era arrays, and %s ly for makeshift ones. "
293 +
"Up to %s sensor arrays can be used.", initPad,
301 }
else if (stageId == Stage.SLIPSTREAM_NAVIGATION) {
302 info.
addPara(
"Fuel use while traveling inside slipstreams reduced by %s. This reduction is multiplicative " +
303 "with the baseline fuel use reduction for traveling inside a slipstream.",
306 }
else if (stageId == Stage.REVERSE_POLARITY) {
307 info.
addPara(
"Unlocks the %s ability, which allows your fleet to "
308 +
"travel against the current of slipstreams.", initPad, h,
310 }
else if (stageId == Stage.GENERATE_SLIPSURGE) {
311 info.
addPara(
"Unlocks the %s ability, which allows your fleet to "
312 +
"create powerful, short-lived slipstreams useful for rapid travel.", initPad, h,
313 "Generate Slipsurge");
314 }
else if (stageId == Stage.HYPERFIELD_OPTIMIZATION) {
315 info.
addPara(
"Maximum burn increased by %s while in hyperspace.", initPad, h,
317 }
else if (stageId == Stage.TOPOGRAPHIC_DATA) {
320 info.
addPara(
"A batch of topographic data that can be sold for a"
321 +
" considerable number of credits.", initPad);
322 info.
addPara(
"Event progress will be reset to between %s and %s points when this outcome is reached.",
323 opad, h,
"" + min,
"" + max);
328 final EventStageData esd =
getDataFor(stageId);
330 if (esd !=
null && EnumSet.of(Stage.SLIPSTREAM_DETECTION, Stage.SLIPSTREAM_NAVIGATION,
331 Stage.GENERATE_SLIPSURGE, Stage.REVERSE_POLARITY,
332 Stage.HYPERFIELD_OPTIMIZATION, Stage.TOPOGRAPHIC_DATA).contains(esd.id)) {
335 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
338 if (esd.id == Stage.SLIPSTREAM_DETECTION) {
339 tooltip.
addTitle(
"Slipstream detection");
340 }
else if (esd.id == Stage.SLIPSTREAM_NAVIGATION) {
341 tooltip.
addTitle(
"Slipstream navigation");
342 }
else if (esd.id == Stage.HYPERFIELD_OPTIMIZATION) {
343 tooltip.
addTitle(
"Hyperfield optimization");
344 }
else if (esd.id == Stage.REVERSE_POLARITY) {
345 tooltip.
addTitle(
"Reverse Polarity");
346 }
else if (esd.id == Stage.GENERATE_SLIPSURGE) {
347 tooltip.
addTitle(
"Generate Slipsurge");
348 }
else if (esd.id == Stage.TOPOGRAPHIC_DATA) {
349 tooltip.
addTitle(
"Topographic data");
354 esd.addProgressReq(tooltip, opad);
371 if (esd ==
null)
return null;
374 if (EnumSet.of(Stage.SLIPSTREAM_DETECTION, Stage.SLIPSTREAM_NAVIGATION, Stage.HYPERFIELD_OPTIMIZATION,
375 Stage.TOPOGRAPHIC_DATA, Stage.START).contains(esd.id)) {
378 if (stageId == Stage.REVERSE_POLARITY) {
381 if (stageId == Stage.GENERATE_SLIPSURGE) {
399 return super.getBarProgressIndicatorColor();
404 return super.getStageImportance(stageId);
410 return "Hyperspace Topography";
429 EventStageData stage =
getDataFor(Stage.GENERATE_SLIPSURGE);
430 return stage.progress;
443 Set<String> tags = super.getIntelTags(map);
451 super.advanceImpl(amount);
464 List<Token> params =
new ArrayList<Token>();
465 Token t =
new Token(
id, TokenType.LITERAL);
467 t =
new Token(
"-1", TokenType.LITERAL);
473 int curr = slots.getCurrBarIndex();
474 OUTER:
for (
int i = 0; i < 5; i++) {
475 slots.setCurrBarIndex(i);
476 for (AbilitySlotAPI slot : slots.getCurrSlotsCopy()) {
487 slots.setCurrBarIndex(curr);
495 if (stage.id == Stage.REVERSE_POLARITY) {
498 if (stage.id == Stage.GENERATE_SLIPSURGE) {
501 if (stage.id == Stage.TOPOGRAPHIC_DATA) {
525 String id1 =
"hypertopology1";
555 String id1 =
"hypertopology1";
556 String id2 =
"hypertopology2";
557 String id3 =
"hypertopology3";
558 String id4 =
"hypertopology4";
560 if (market.isHidden())
continue;
562 boolean unapplicable =
false;
564 if (spaceport ==
null) {
572 if (!market.isPlayerOwned() || unapplicable) {
581 mod.
modifyFlat(id2, market.getSize(),
"Colony size");
594 int countMakeshift= 0;
598 if (dist > range && Math.round(dist * 10f) <= range * 10f) {
603 if (entity.getFaction() !=
null && entity.getFaction().isPlayerFaction()) {
616 if (useMakeshift < 0) useMakeshift = 0;
637 for (RecentTopographyReadings curr :
recent.getItems()) {
647 if (stageId == Stage.REVERSE_POLARITY || stageId == Stage.GENERATE_SLIPSURGE) {
648 return "ui_learned_ability";
650 return super.getSoundForStageReachedUpdate(stageId);
static SettingsAPI getSettings()
static SectorAPI getSector()
void unmodifyMult(String source)
void modifyMult(String source, float value)
HashMap< String, StatMod > getMultMods()
void modifyFlatAlways(String source, float value, String desc)
void modifyFlat(String source, float value)
void unmodifyFlat(String source)
static final String SCAVENGE
static final String REVERSE_POLARITY
static final String GENERATE_SLIPSURGE
static final String DISTRESS_CALL
static final String SPACEPORT
static final String MEGAPORT
static final String TOPOGRAPHIC_DATA
static final String SLIPSTREAM_REVEAL_RANGE_LY_MOD
static final String FUEL_USE_NOT_SHOWN_ON_MAP_MULT
Object getListInfoParam()
void addFactor(EventFactor factor)
void addStage(Object id, int progress)
boolean isStageActive(Object stageId)
void setMaxProgress(int maxProgress)
EventStageData getDataFor(Object stageId)
void setProgress(int progress)
boolean addEventFactorBulletPoints(TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
List< EventStageData > stages
List< EventFactor > factors
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
void resetTopographicData()
boolean withMonthlyFactors()
static boolean hasRecentReadingsNearPlayer()
static float RANGE_PER_MAKESHIFT_SENSOR_ARRAY
void addStageDesc(TooltipMakerAPI info, Object stageId, float initPad, boolean forTooltip)
void addStageDescriptionText(TooltipMakerAPI info, float width, Object stageId)
void notifyStageReached(EventStageData stage)
TooltipCreator getStageTooltipImpl(Object stageId)
static float SLIPSTREAM_FUEL_MULT
String getSoundForOneTimeFactorUpdate(EventFactor factor)
void updateMarketDetectionRanges()
static float RECENT_READINGS_TIMEOUT
static float RECENT_READINGS_RANGE_LY
String getSoundForStageReachedUpdate(Object stageId)
Set< String > getIntelTags(SectorMapAPI map)
static float BASE_DETECTION_RANGE_LY
void reportCurrentLocationChanged(LocationAPI prev, LocationAPI curr)
static float HYPER_BURN_BONUS
float gerSensorArrayBonusFor(MarketAPI market, float range)
static void addFactorCreateIfNecessary(EventFactor factor, InteractionDialogAPI dialog)
static float WAYSTATION_BONUS
void reportRefreshedCharacterStatEffects()
int getStageImportance(Object stageId)
String getStageIconImpl(Object stageId)
void addRecentReadings(Vector2f loc)
static int MAX_SENSOR_ARRAYS
TimeoutTracker< RecentTopographyReadings > recent
float getImageIndentForStageDesc(Object stageId)
boolean hasRecentReadingsNear(Vector2f loc)
void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param)
void advanceImpl(float amount)
void reportAboutToRefreshCharacterStatEffects()
HyperspaceTopographyEventIntel(TextPanelAPI text, boolean withIntelNotification)
Color getBarProgressIndicatorColor()
void addAbility(String id)
void reportBattleOccurred(CampaignFleetAPI fleet, CampaignFleetAPI primaryWinner, BattleAPI battle)
float getImageSizeForStageDesc(Object stageId)
static float RANGE_WITHIN_WHICH_SENSOR_ARRAYS_HELP_LY
static float RANGE_PER_DOMAIN_SENSOR_ARRAY
boolean execute(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
static String FUEL_USE_MODIFIER_DESC
static float getDistanceLY(SectorEntityToken from, SectorEntityToken to)
static Color getHighlightColor()
static Color interpolateColor(Color from, Color to, float progress)
AbilitySpecAPI getAbilitySpec(String abilityId)
String getSpriteName(String category, String id)
Color getColor(String id)
float convertToDays(float realSeconds)
MutableFleetStatsAPI getStats()
void addSpecial(SpecialItemData data, float quantity)
AbilitySlotsAPI getAbilitySlotsAPI()
CampaignFleetAPI getPlayerFleet()
List< StarSystemAPI > getStarSystems()
CampaignClockAPI getClock()
LocationAPI getCurrentLocation()
PersistentUIDataAPI getUIData()
IntelManagerAPI getIntelManager()
MemoryAPI getMemoryWithoutUpdate()
boolean hasAbility(String id)
Vector2f getLocationInHyperspace()
void addIntel(IntelInfoPlugin plugin)
List< MarketAPI > getMarketsCopy()
Vector2f getLocationInHyperspace()
void set(String key, Object value)
StatBonus getFleetwideMaxBurnMod()
DynamicStatsAPI getDynamic()
MutableStat getStat(String id)