1package com.fs.starfarer.api.impl.campaign.abilities;
4import java.util.ArrayList;
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.Script;
9import com.fs.starfarer.api.campaign.CampaignFleetAPI;
10import com.fs.starfarer.api.campaign.FactionAPI;
11import com.fs.starfarer.api.campaign.rules.MemoryAPI;
12import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActions;
13import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
14import com.fs.starfarer.api.ui.LabelAPI;
15import com.fs.starfarer.api.ui.TooltipMakerAPI;
16import com.fs.starfarer.api.util.Misc;
30 return "Transponder on";
46 if (
entity.isPlayerFleet()) {
48 if (!factions.isEmpty()) {
49 Global.
getSector().getCampaignUI().addMessage(
"Your identity is revealed and linked to your recent hostile actions!");
50 for (FactionAPI faction : factions) {
51 Global.
getSector().adjustPlayerReputation(RepActions.COMBAT_NORMAL, faction.getId());
56 entity.setTransponderOn(
true);
57 entity.getMemoryWithoutUpdate().set(MemFlags.JUST_TOGGLED_TRANSPONDER,
true, 0.1f);
68 if (fleet ==
null)
return;
83 if (
entity.isTransponderOn()) {
84 entity.setTransponderOn(
false);
85 entity.getMemoryWithoutUpdate().set(MemFlags.JUST_TOGGLED_TRANSPONDER,
true, 0.1f);
93 entity.setTransponderOn(
false);
94 entity.getMemoryWithoutUpdate().set(MemFlags.JUST_TOGGLED_TRANSPONDER,
true, 0.1f);
111 CampaignFleetAPI fleet =
getFleet();
112 if (fleet ==
null)
return;
114 fleet.getStats().getDetectedRangeMod().unmodify(
getModId());
119 Color gray = Misc.getGrayColor();
120 Color highlight = Misc.getHighlightColor();
121 Color red = Misc.getNegativeHighlightColor();
123 String status =
" (off)";
124 if (
entity.isTransponderOn()) {
128 LabelAPI title = tooltip.addTitle(
spec.getName() + status);
129 title.highlightLast(status);
130 title.setHighlightColor(gray);
133 tooltip.addPara(
"Transponders transmit identifying information to all fleets within range.", pad);
136 if (!factions.isEmpty()) {
137 String text =
"Turning the transponder on now would reveal your hostile actions to";
138 boolean first =
true;
139 boolean last =
false;
140 for (FactionAPI faction : factions) {
141 last = factions.indexOf(faction) == factions.size() - 1;
142 if (first || !last) {
143 text +=
" " + faction.getDisplayNameWithArticle() +
",";
145 text +=
" and " + faction.getDisplayNameWithArticle() +
",";
148 text = text.substring(0, text.length() - 1) +
".";
149 tooltip.addPara(text, red, pad);
152 tooltip.addPara(
"When the transponder is on, your fleet can be detected at longer range and " +
153 "full information on its composition is available at maximum range.", pad);
154 tooltip.addPara(
"Transponder status also affects the reputation changes from combat and trade. " +
155 "With it turned off, you might be able to trade with otherwise inhospitable factions.", pad);
156 tooltip.addPara(
"In most places, running with the transponder off will attract the attention of nearby patrols, " +
157 "although several factions and certain free ports allow it. " +
158 "Having the transponder off does not grant perfect anonymity.", pad);
167 boolean first =
true;
168 boolean last =
false;
169 for (FactionAPI faction : factions) {
170 last = factions.indexOf(faction) == factions.size() - 1;
171 if (first || !last) {
172 text +=
" " + faction.getDisplayNameLongWithArticle() +
",";
174 text +=
" and " + faction.getDisplayNameLongWithArticle() +
",";
177 text = text.substring(0, text.length() - 1) +
"";
191 List<FactionAPI> result =
new ArrayList<FactionAPI>();
193 if (fleet ==
null)
return result;
194 if (fleet.getContainingLocation() ==
null)
return result;
195 if (fleet.isTransponderOn())
return result;
197 List<CampaignFleetAPI> fleets = fleet.getContainingLocation().getFleets();
198 for (CampaignFleetAPI other : fleets) {
199 if (other.getFleetData().getNumMembers() <= 0)
continue;
204 float dist = Misc.getDistance(fleet.getLocation(), other.getLocation());
205 fleet.setTransponderOn(
true);
207 fleet.setTransponderOn(
false);
209 if (dist > detectRange)
continue;
211 MemoryAPI mem = other.getMemoryWithoutUpdate();
213 if (mem.getBoolean(MemFlags.MEMORY_KEY_LOW_REP_IMPACT))
continue;
215 if (!result.contains(other.getFaction()) &&
216 mem.getBoolean(MemFlags.MEMORY_KEY_MAKE_HOSTILE_WHILE_TOFF) &&
217 !other.getFaction().isHostileTo(fleet.getFaction())) {
218 result.add(other.getFaction());
224 private transient boolean showAlarm =
false;
228 super.advance(amount);
231 CampaignFleetAPI fleet =
getFleet();
232 if (fleet ==
null || !fleet.isPlayerFleet())
return;
233 sinceWarning += amount;
236 if (factions.isEmpty()) {
262 Color color = Misc.getNegativeHighlightColor();
263 return Misc.scaleAlpha(color,
Global.
getSector().getCampaignUI().getSharedFader().getBrightness());
273 sinceWarning = 1000f;
277 transient float sinceWarning = 1000f;
283 if (
entity.isPlayerFleet()) {
285 if (!factions.isEmpty()) {
287 String text =
"Turning the transponder on will reveal your identity and make " + list +
" hostile.\n\n" +
288 "Are you sure you want to do this?";
289 Global.
getSector().getCampaignUI().showConfirmDialog(text,
"Confirm",
"Cancel",
295 sinceWarning = 1000f;
302 sinceWarning = 1000f;
308 sinceWarning = 1000f;
330 return "Transponder shutdown initiated - use again to deactivate";
334 return "Activating the transponder will reveal your identity - use again to confirm";
336 return "Transponder primed - use again to activate";
345 return super.getCooldownFraction();
358 Color color = Misc.getNegativeHighlightColor();
361 color = Misc.getHighlightColor();
366 if (sinceWarning < t) {
367 b = sinceWarning / t;
372 return Misc.scaleAlpha(color,
Global.
getSector().getCampaignUI().getSharedFader().getBrightness() * 0.75f * b);
374 return super.getCooldownColor();
static SectorAPI getSector()
transient AbilitySpecAPI spec
CampaignFleetAPI getFleet()
void addIncompatibleToTooltip(TooltipMakerAPI tooltip, boolean expanded)
float getCooldownFraction()
void createTooltip(TooltipMakerAPI tooltip, boolean expanded)
String getDeactivationText()
boolean isCooldownRenderingAdditive()
static final float DETECTABILITY_MULT
static final float DETECTABILITY_FLAT
boolean showProgressIndicator()
String getActivationMessage()
String getActivationText()
void advance(float amount)
static List< FactionAPI > getFactionsThatWouldBecomeHostile(CampaignFleetAPI fleet)
List< FactionAPI > getFactionsThatWouldBecomeHostile()
static final float CONFIRM_DURATION
float getProgressFraction()
String getFactionList(List< FactionAPI > factions)
void applyEffect(float amount, float level)
String getDeactivationMessage()