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() {
32 if (entity.isInCurrentLocation()) {
33 //entity.addFloatingText("Active sensor burst", entity.getFaction().getBaseUIColor(), 0.5f);
34
35 VisibilityLevel level = entity.getVisibilityLevelToPlayerFleet();
36 if (level != VisibilityLevel.NONE) {
37 Global.getSector().addPing(entity, Pings.SENSOR_BURST);
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
66 if (entity.isInCurrentLocation()) {
67 Global.getSector().getMemoryWithoutUpdate().set(MemFlags.GLOBAL_SENSOR_BURST_JUST_USED_IN_CURRENT_LOCATION, true, 0.1f);
68 }
69 fleet.getMemoryWithoutUpdate().set(MemFlags.JUST_DID_SENSOR_BURST, true, 0.1f);
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");
82 fleet.getStats().getDetectedRangeMod().modifyFlat(getModId(), DETECTABILITY_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
99 fleet.getStats().getSensorRangeMod().unmodify(getModId());
100 fleet.getStats().getDetectedRangeMod().unmodify(getModId());
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
130 LabelAPI title = tooltip.addTitle(spec.getName());
131// title.highlightLast(status);
132// title.setHighlightColor(gray);
133
134 float pad = 10f;
135 tooltip.addPara("Turn off engines to reduce interference and link all sensors in the fleet into a single network.", pad);
136 tooltip.addPara("Increases sensor range by %s* units and" +
137 " increases the range at which the fleet can be detected by %s* units." +
138 " The fleet is only able to %s** while the ability is active.",
139 pad, highlight,
140 "" + (int)SENSOR_RANGE_BONUS,
142 "move slowly"
143 );
144 //tooltip.addPara("Disables \"Go Dark\" when activated.", pad);
145 tooltip.addPara("*2000 units = 1 map grid cell", gray, pad);
146 tooltip.addPara("**A fleet is considered slow-moving at a burn level of half that of its slowest ship.", gray, 0f);
147// tooltip.addPara("**Maximum burn level of %s", 0f, gray,
148// Misc.getDarkHighlightColor(),
149// "" + Misc.getGoSlowBurnLevel(getFleet()));
150
151 addIncompatibleToTooltip(tooltip, expanded);
152
153 }
154
155 public boolean hasTooltip() {
156 return true;
157 }
158
159}
160
161
162
163
164
static SectorAPI getSector()
Definition Global.java:59
void addIncompatibleToTooltip(TooltipMakerAPI tooltip, boolean expanded)
void createTooltip(TooltipMakerAPI tooltip, boolean expanded)