Starsector API
Loading...
Searching...
No Matches
RemnantNexusActivityCause.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.events;
2
3import java.awt.Color;
4import java.util.LinkedHashSet;
5import java.util.Set;
6
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.CampaignFleetAPI;
9import com.fs.starfarer.api.campaign.StarSystemAPI;
10import com.fs.starfarer.api.impl.campaign.ids.Factions;
11import com.fs.starfarer.api.ui.Alignment;
12import com.fs.starfarer.api.ui.MapParams;
13import com.fs.starfarer.api.ui.TooltipMakerAPI;
14import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
15import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipLocation;
16import com.fs.starfarer.api.ui.UIPanelAPI;
17import com.fs.starfarer.api.util.Misc;
18
20
21 public static float MAX_MAG = 0.5f;
22
23 public static int PROGRESS_NEXUS_DAMAGED = Global.getSettings().getInt("remnantNexusPointsDamaged");
24 public static int PROGRESS_NEXUS_NORMAL = Global.getSettings().getInt("remnantNexusPointsNormal");
25
29
30 @Override
32 Set<CampaignFleetAPI> seen = new LinkedHashSet<CampaignFleetAPI>();
33 for (final StarSystemAPI system : Misc.getSystemsWithPlayerColonies(false)) {
35 if (nexus == null) continue;
36
37 if (nexus == null || seen.contains(nexus)) continue;
38
39
40 int numColonies = Misc.getMarketsInLocation(system, Factions.PLAYER).size();
41 final String colonies = numColonies != 1 ? "colonies" : "colony";
42 final String isOrAre = numColonies != 1 ? "are" : "is";
43
44 String desc = "Remnant Nexus in the " + system.getNameWithLowercaseTypeShort();
45
46 final int progress = getProgressForNexus(nexus);
47 String progressStr = "+" + progress;
48 if (progress < 0) progressStr = "" + progress;
49 Color descColor = getDescColor(intel);
50 Color progressColor = getProgressColor(intel);
51
52 info.addRowWithGlow(Alignment.LMID, descColor, " " + desc,
53 Alignment.RMID, progressColor, progressStr);
54
56 @Override
57 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
58 float opad = 10f;
59
60 MapParams params = new MapParams();
61 params.showSystem(system);
62
63 float w = tooltip.getWidthSoFar();
64 float h = Math.round(w / 1.6f);
65 params.positionToShowAllMarkersAndSystems(true, Math.min(w, h));
66
67 //UIPanelAPI map = tooltip.createSectorMap(w, h, params, aStr + " " + Misc.ucFirst(systems));
68 UIPanelAPI map = tooltip.createSectorMap(w, h, params, system.getNameWithLowercaseType());
69
70 tooltip.addPara("Your " + colonies + " in the " + system.getNameWithLowercaseTypeShort() +
71 " " + isOrAre + " threatened by a Remnant Nexus located in the system. " +
72 "This results in a greater risk of trade fleets being attacked, and eventual "
73 + "existential danger for your " + colonies + ".", 0f, Misc.getNegativeHighlightColor(),
74 "existential danger for your " + colonies);
75
76 tooltip.addPara("Even when relatively dormant, " +
77 "the Remnant fleets are a constant thorn in your side, wasting defensive resources and "
78 + "exposing your " + colonies +
79 " to other dangers.", opad);
80
81 tooltip.addPara("%s should address all these concerns.", opad,
82 Misc.getHighlightColor(), "Destroying the Nexus");
83
84 tooltip.addCustom(map, opad);
85 }
86 };
87 info.addTooltipToAddedRow(t, TooltipLocation.RIGHT, false);
88 }
89 }
90
91 @Override
92 public boolean shouldShow() {
93 return getProgress() != 0;
94 }
95
96 public int getProgress() {
97 int total = 0;
98 for (final StarSystemAPI system : Misc.getSystemsWithPlayerColonies(false)) {
100 if (nexus == null) continue;
101 total += getProgressForNexus(nexus);
102 }
103 return total;
104 }
105
106
108 if (nexus == null) return 0;
109
110 boolean damaged = nexus.getMemoryWithoutUpdate().getBoolean("$damagedStation");
111 if (damaged) {
113 }
115 }
116
117
118
119 public String getDesc() {
120 return null;
121 }
122
124 if (getProgress() <= 0) return 0f;
125
127 if (nexus == null) return 0f;
128
129 boolean damaged = nexus.getMemoryWithoutUpdate().getBoolean("$damagedStation");
130 if (damaged) {
131 return MAX_MAG * 0.5f;
132 }
133
134 return MAX_MAG;
135 }
136
137
138}
139
140
static SettingsAPI getSettings()
Definition Global.java:57
void showSystem(StarSystemAPI system)
void positionToShowAllMarkersAndSystems(boolean showPlayerFleet, float heightOnScreen)
static List< StarSystemAPI > getSystemsWithPlayerColonies(boolean includeNonPlayerFaction)
Definition Misc.java:996
static List< MarketAPI > getMarketsInLocation(LocationAPI location, String factionId)
Definition Misc.java:936
static Color getNegativeHighlightColor()
Definition Misc.java:802
static Color getHighlightColor()
Definition Misc.java:792
UIComponentAPI addCustom(UIComponentAPI comp, float pad)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
UIPanelAPI createSectorMap(float w, float h, MapParams p, String title)
Object addRowWithGlow(Object ... data)
void addTooltipToAddedRow(TooltipCreator tc, TooltipLocation loc)