Starsector API
Loading...
Searching...
No Matches
SensorBurstAbility.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.abilities;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.CampaignFleetAPI;
7import com.fs.starfarer.api.campaign.SectorEntityToken.VisibilityLevel;
8import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
9import com.fs.starfarer.api.impl.campaign.ids.Pings;
10import com.fs.starfarer.api.ui.LabelAPI;
11import com.fs.starfarer.api.ui.TooltipMakerAPI;
12import com.fs.starfarer.api.util.Misc;
13
15
16 public static final float SENSOR_RANGE_BONUS = 3000f;
17 public static final float DETECTABILITY_RANGE_BONUS = 5000f;
18 //public static final float ACCELERATION_MULT = 4f;
19
20// public String getSpriteName() {
21// return Global.getSettings().getSpriteName("abilities", Abilities.SENSOR_BURST);
22// }
23
24// @Override
25// protected String getActivationText() {
26// //return "Active sensor burst";
27// return Misc.ucFirst(spec.getName().toLowerCase());
28// }
29
30 @Override
31 protected void activateImpl() {
33 //entity.addFloatingText("Active sensor burst", entity.getFaction().getBaseUIColor(), 0.5f);
34
36 if (level != VisibilityLevel.NONE) {
38 }
39 }
40
41// AbilityPlugin goDark = entity.getAbility(Abilities.GO_DARK);
42// if (goDark != null && goDark.isActive()) {
43// goDark.deactivate();
44// }
45// AbilityPlugin sb = entity.getAbility(Abilities.SUSTAINED_BURN);
46// if (sb != null && sb.isActive()) {
47// sb.deactivate();
48// }
49 }
50
51 @Override
52 protected void applyEffect(float amount, float level) {
53// if (level > 0) {
54// AbilityPlugin goDark = entity.getAbility(Abilities.GO_DARK);
55// if (goDark != null) goDark.forceDisable();
56// AbilityPlugin eb = entity.getAbility(Abilities.EMERGENCY_BURN);
57// if (eb != null) eb.forceDisable();
58// AbilityPlugin sb = entity.getAbility(Abilities.SUSTAINED_BURN);
59// if (sb != null) sb.forceDisable();
60// }
61
62
63 CampaignFleetAPI fleet = getFleet();
64 if (fleet == null) return;
65
68 }
70
71// if (fleet.isPlayerFleet()) {
72// System.out.println("Level: " + level);
73// }
74
75 //float b = fleet.getStats().getDynamic().getValue(Stats.SENSOR_BURST_BURN_PENALTY_MULT);
76
77 //fleet.getStats().getFleetwideMaxBurnMod().modifyMult(getModId(), 1f + (0f - 1f * level) * b, "Active sensor burst");
78 //fleet.getStats().getFleetwideMaxBurnMod().modifyMult(getModId(), 1f + (0f - 1f * 1f) * b, "Active sensor burst");
79 //fleet.getStats().getFleetwideMaxBurnMod().modifyMult(getModId(), 0, "Active sensor burst");
80
81 fleet.getStats().getSensorRangeMod().modifyFlat(getModId(), SENSOR_RANGE_BONUS * level, "Active sensor burst");
83
84 //fleet.getStats().getAccelerationMult().modifyMult(getModId(), 1f + (ACCELERATION_MULT - 1f) * level);
85
86 fleet.goSlowOneFrame();
87 }
88
89 @Override
90 protected void deactivateImpl() {
92 }
93
94 @Override
95 protected void cleanupImpl() {
96 CampaignFleetAPI fleet = getFleet();
97 if (fleet == null) return;
98
101 //fleet.getStats().getFleetwideMaxBurnMod().unmodify(getModId());
102 //fleet.getStats().getAccelerationMult().unmodify(getModId());
103 }
104
105// @Override
106// public float getActivationDays() {
107// return 0.2f;
108// }
109//
110// @Override
111// public float getCooldownDays() {
112// return 1f;
113// }
114//
115// @Override
116// public float getDeactivationDays() {
117// return 0.2f;
118// }
119//
120// @Override
121// public float getDurationDays() {
122// return 0.5f;
123// }
124
125 @Override
126 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded) {
127 Color gray = Misc.getGrayColor();
128 Color highlight = Misc.getHighlightColor();
129
131 LabelAPI title = tooltip.addTitle(spec.getName());
132 } else {
133 tooltip.addSpacer(-10f);
134 }
135
136 float pad = 10f;
137 tooltip.addPara("Turn off engines to reduce interference and link all sensors in the fleet into a single network.", pad);
138 tooltip.addPara("Increases sensor range by %s* units and" +
139 " increases the range at which the fleet can be detected by %s* units." +
140 " The fleet is only able to %s** while the ability is active.",
141 pad, highlight,
142 "" + (int)SENSOR_RANGE_BONUS,
144 "move slowly"
145 );
146 //tooltip.addPara("Disables \"Go Dark\" when activated.", pad);
147 tooltip.addPara("*2000 units = 1 map grid cell", gray, pad);
148 tooltip.addPara("**A fleet is considered slow-moving at a burn level of half that of its slowest ship.", gray, 0f);
149// tooltip.addPara("**Maximum burn level of %s", 0f, gray,
150// Misc.getDarkHighlightColor(),
151// "" + Misc.getGoSlowBurnLevel(getFleet()));
152
153 addIncompatibleToTooltip(tooltip, expanded);
154
155 }
156
157 public boolean hasTooltip() {
158 return true;
159 }
160
161}
162
163
164
165
166
static boolean CODEX_TOOLTIP_MODE
Definition Global.java:15
static SectorAPI getSector()
Definition Global.java:65
void modifyFlat(String source, float value)
void addIncompatibleToTooltip(TooltipMakerAPI tooltip, boolean expanded)
void createTooltip(TooltipMakerAPI tooltip, boolean expanded)
static final String GLOBAL_SENSOR_BURST_JUST_USED_IN_CURRENT_LOCATION
Definition MemFlags.java:49
static Color getGrayColor()
Definition Misc.java:826
static Color getHighlightColor()
Definition Misc.java:792
EveryFrameScript addPing(SectorEntityToken entity, String pingType)
void set(String key, Object value)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
UIComponentAPI addSpacer(float height)