Starsector API
Loading...
Searching...
No Matches
WarningBeaconIntel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.misc;
2
3import java.awt.Color;
4import java.util.Set;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.FactionAPI;
8import com.fs.starfarer.api.campaign.SectorEntityToken;
9import com.fs.starfarer.api.campaign.StarSystemAPI;
10import com.fs.starfarer.api.impl.campaign.ids.Factions;
11import com.fs.starfarer.api.impl.campaign.ids.Tags;
12import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
13import com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantThemeGenerator.RemnantSystemType;
14import com.fs.starfarer.api.loading.Description;
15import com.fs.starfarer.api.loading.Description.Type;
16import com.fs.starfarer.api.ui.SectorMapAPI;
17import com.fs.starfarer.api.ui.TooltipMakerAPI;
18import com.fs.starfarer.api.util.Misc;
19
20public class WarningBeaconIntel extends BaseIntelPlugin {
21
22 protected SectorEntityToken beacon;
23
24 public WarningBeaconIntel(SectorEntityToken beacon) {
25 this.beacon = beacon;
26 //Global.getSector().getIntelManager().addIntel(this);
27 }
28
29 protected RemnantSystemType getRemnantType() {
30 RemnantSystemType remnantType = null;
31 if (beacon.getMemoryWithoutUpdate().contains(RemnantSystemType.DESTROYED.getBeaconFlag())) {
32 remnantType = RemnantSystemType.DESTROYED;
33 } else if (beacon.getMemoryWithoutUpdate().contains(RemnantSystemType.SUPPRESSED.getBeaconFlag())) {
34 remnantType = RemnantSystemType.SUPPRESSED;
35 } else if (beacon.getMemoryWithoutUpdate().contains(RemnantSystemType.RESURGENT.getBeaconFlag())) {
36 remnantType = RemnantSystemType.RESURGENT;
37 }
38 return remnantType;
39 }
40
41 protected boolean isLow() {
42 return beacon.hasTag(Tags.BEACON_LOW);
43 }
44 protected boolean isMedium() {
45 return beacon.hasTag(Tags.BEACON_MEDIUM);
46 }
47 protected boolean isHigh() {
48 return beacon.hasTag(Tags.BEACON_HIGH);
49 }
50
51 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
52
53 Color h = Misc.getHighlightColor();
54 Color g = Misc.getGrayColor();
55 float pad = 3f;
56 float opad = 10f;
57
58 float initPad = pad;
59 if (mode == ListInfoMode.IN_DESC) initPad = opad;
60
61 Color tc = getBulletColorForMode(mode);
62
63 bullet(info);
64 boolean isUpdate = getListInfoParam() != null;
65
66 String danger = null;
67 Color dangerColor = null;
68 if (isLow()) {
69 danger = "low";
70 dangerColor = Misc.getPositiveHighlightColor();
71 } else if (isMedium()) {
72 danger = "medium";
73 dangerColor = h;
74 } else if (isHigh()) {
75 danger = "high";
76 dangerColor = Misc.getNegativeHighlightColor();
77 }
78
79 if (danger != null) {
80 info.addPara("Danger level: " + danger, initPad, tc, dangerColor, danger);
81 initPad = 0f;
82 }
83
84 unindent(info);
85 }
86
87
88 @Override
89 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
90 Color c = getTitleColor(mode);
91 info.addPara(getName(), c, 0f);
92 addBulletPoints(info, mode);
93 }
94
95 @Override
96 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
97 Color h = Misc.getHighlightColor();
98 Color g = Misc.getGrayColor();
99 Color tc = Misc.getTextColor();
100 float pad = 3f;
101 float opad = 10f;
102
103
104 Description desc = Global.getSettings().getDescription("warning_beacon", Type.CUSTOM);
105 info.addPara(desc.getText1FirstPara(), opad);
106
107 addBulletPoints(info, ListInfoMode.IN_DESC);
108
109 if (beacon.isInHyperspace()) {
110 StarSystemAPI system = Misc.getNearbyStarSystem(beacon, 1f);
111 if (system != null) {
112 info.addPara("This beacon is located near the " + system.getNameWithLowercaseType() +
113 ", warning of dangers that presumably lie within.", opad);
114
115 }
116 }
117 }
118
119 @Override
120 public String getIcon() {
121 if (isLow()) {
122 return Global.getSettings().getSpriteName("intel", "beacon_low");
123 } else if (isMedium()) {
124 return Global.getSettings().getSpriteName("intel", "beacon_medium");
125 } else if (isHigh()) {
126 return Global.getSettings().getSpriteName("intel", "beacon_high");
127 }
128 return Global.getSettings().getSpriteName("intel", "beacon_low");
129 }
130
131 @Override
132 public Set<String> getIntelTags(SectorMapAPI map) {
133 Set<String> tags = super.getIntelTags(map);
134 tags.add(Tags.INTEL_BEACON);
135
136 if (getRemnantType() != null) {
137 tags.add(Factions.REMNANTS);
138 }
139
140 return tags;
141 }
142
143 public String getSortString() {
144 if (isLow()) {
145 return "Warning Beacon 3";
146 } else if (isMedium()) {
147 return "Warning Beacon 2";
148 } else if (isHigh()) {
149 return "Warning Beacon 1";
150 }
151 return "Warning Beacon 0";
152 }
153
154 public String getName() {
155// if (isLow()) {
156// return "Warning Beacon (Low)";
157// } else if (isMedium()) {
158// return "Warning Beacon (Medium)";
159// } else if (isHigh()) {
160// return "Warning Beacon (High)";
161// }
162 return "Warning Beacon";
163 }
164
165 @Override
166 public FactionAPI getFactionForUIColors() {
167 return super.getFactionForUIColors();
168 }
169
170 public String getSmallDescriptionTitle() {
171 return getName();
172 }
173
174 @Override
175 public SectorEntityToken getMapLocation(SectorMapAPI map) {
176 if (beacon.isInHyperspace() && false) {
177 StarSystemAPI system = Misc.getNearbyStarSystem(beacon, 1f);
178 if (system != null) {
179 return system.getHyperspaceAnchor();
180 }
181 }
182 return beacon;
183 }
184
185 @Override
186 public boolean shouldRemoveIntel() {
187 return false;
188 }
189
190 @Override
191 public String getCommMessageSound() {
192 return "ui_discovered_entity";
193 }
194
195
196
197}
198
199
200
201
202
203
204
static SettingsAPI getSettings()
Definition Global.java:51
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
Description getDescription(String id, Type type)
String getSpriteName(String category, String id)