Starsector API
Loading...
Searching...
No Matches
CoreDiscoverEntityPlugin.java
Go to the documentation of this file.
1package com.fs.starfarer.api.campaign.listeners;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.EveryFrameScript;
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.CampaignFleetAPI;
8import com.fs.starfarer.api.campaign.CargoAPI;
9import com.fs.starfarer.api.campaign.InteractionDialogAPI;
10import com.fs.starfarer.api.campaign.LocationAPI;
11import com.fs.starfarer.api.campaign.PlanetAPI;
12import com.fs.starfarer.api.campaign.SectorEntityToken;
13import com.fs.starfarer.api.campaign.SectorEntityToken.VisibilityLevel;
14import com.fs.starfarer.api.campaign.StarSystemAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Factions;
16import com.fs.starfarer.api.impl.campaign.ids.Tags;
17import com.fs.starfarer.api.impl.campaign.intel.MessageIntel;
18import com.fs.starfarer.api.impl.campaign.intel.misc.RemnantNexusIntel;
19import com.fs.starfarer.api.impl.campaign.intel.misc.SalvorsTallyIntel;
20import com.fs.starfarer.api.impl.campaign.intel.misc.SalvorsTallyIntel.SalvageValue;
21import com.fs.starfarer.api.impl.campaign.intel.misc.SalvorsTallyIntel.SalvorsTally;
22import com.fs.starfarer.api.impl.campaign.intel.misc.WarningBeaconIntel;
23import com.fs.starfarer.api.impl.campaign.procgen.SalvageEntityGenDataSpec;
24import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.StarSystemType;
25import com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionIntel;
26import com.fs.starfarer.api.util.Misc;
27
30
35 public static float SALVORS_TALLY_DELAY_SECONDS = 10f;
36
37 public void discoverEntity(SectorEntityToken entity) {
38
39 entity.setDiscoverable(null);
40 entity.setSensorProfile(null);
41
42 if (entity.hasTag(Tags.WARNING_BEACON)) {
43 WarningBeaconIntel intel = new WarningBeaconIntel(entity);
45 } else {
47 MessageIntel intel = new MessageIntel("Discovered: " + entity.getName(),
48 c, new String[] {entity.getName()}, c);
49 intel.setSound("ui_discovered_entity");
50 intel.setIcon(Global.getSettings().getSpriteName("intel", "discovered_entity"));
52 }
53
54
55
56 float xp = 0;
57 if (entity.hasDiscoveryXP()) {
58 xp = entity.getDiscoveryXP();
59 } else if (entity.getCustomEntityType() != null) {
61 if (salvageSpec != null) {
62 xp = salvageSpec.getXpDiscover();
63 }
64 }
65 if (xp > 0) {
67 }
68
70
71 if (entity.hasTag(Tags.SALVAGEABLE)) {
73 }
74 }
75
76
77 public int getHandlingPriority(Object params) {
78 return 0;
79 }
80
81
82 @Override
84 if (prev instanceof StarSystemAPI) {
85 StarSystemAPI system = (StarSystemAPI) prev;
87 }
88 if (curr instanceof StarSystemAPI) {
89 StarSystemAPI system = (StarSystemAPI) curr;
91 }
92 }
93
94 @Override
96 if (Misc.hasUnexploredRuins(planet.getMarket())) {
98 }
99 }
100
101 @Override
103 SectorEntityToken target = dialog.getInteractionTarget();
104 if (target == null) return;
105 if (!target.hasTag(Tags.SALVAGEABLE)) return;
106 if (target.getStarSystem() == null) return;
107
109 }
110
111 @Override
112 public void reportDetectedEntity(SectorEntityToken entity, VisibilityLevel level) {
113 //System.out.println("Detected entity: " + entity.getName() + " - " + level.name());
114 if (entity instanceof CampaignFleetAPI && level == VisibilityLevel.COMPOSITION_AND_FACTION_DETAILS) {
115 CampaignFleetAPI fleet = (CampaignFleetAPI) entity;
116 if (fleet.isStationMode() && fleet.getFaction().getId().equals(Factions.REMNANTS)) {
118 }
119
120 }
121 }
122
123
125 if (RemnantNexusIntel.getNexusIntel(nexus) == null) {
126 new RemnantNexusIntel(nexus); // adds the intel
127 }
128 }
129
130
131 public static class SalvorsTallyAdder implements EveryFrameScript {
132
133 protected float delay = 0f;
134 protected boolean done = false;
135 protected SalvorsTallyIntel intel;
136
137 public SalvorsTallyAdder(SalvorsTallyIntel intel, float delay) {
138 this.delay = delay;
139 this.intel = intel;
140 }
141
142 @Override
143 public boolean isDone() {
144 return done;
145 }
146
147 @Override
148 public boolean runWhilePaused() {
149 return false;
150 }
151
152 @Override
153 public void advance(float amount) {
154 delay -= amount;
155 if (delay <= 0) {
156 done = true;
157 SalvorsTally tally = intel.computeTally();
158 if (tally.value != SalvageValue.NONE) {
159 Global.getSector().getIntelManager().addIntel(intel);
160 }
161 }
162 }
163
164 }
165
166 public static void addSalvorsTallyIfNeeded(StarSystemAPI system) {
167 if (system == null) return;
168 if (system.hasTag(Tags.THEME_CORE)) return;
169 if (system.getType() == StarSystemType.DEEP_SPACE) return;
171
173 if (intel == null) {
174 // Delay adding so it doesn't necessarily pop up for every little thing you see and
175 // immediately salvage
177 if (curr instanceof SalvorsTallyAdder) {
178 SalvorsTallyAdder adder = (SalvorsTallyAdder) curr;
179 if (adder.intel.getSystem() == system) {
180 adder.delay = SALVORS_TALLY_DELAY_SECONDS;
181 return;
182 }
183 }
184 }
185
186 intel = new SalvorsTallyIntel(system);
187 SalvorsTally tally = intel.computeTally();
188 if (tally.value != SalvageValue.NONE) {
189 SalvorsTallyAdder adder = new SalvorsTallyAdder(intel, SALVORS_TALLY_DELAY_SECONDS);
190 Global.getSector().addScript(adder);
191 //Global.getSector().getIntelManager().addIntel(intel);
192 }
193 }
194 }
195
197 if (system == null) return;
199 if (intel != null) {
200 SalvorsTally tally = intel.computeTally();
201 if (tally.value == SalvageValue.NONE) {
202 intel.endImmediately();
203 }
204 }
205 }
206
207
208}
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog)
void reportDetectedEntity(SectorEntityToken entity, VisibilityLevel level)
static void reportEntityDiscovered(SectorEntityToken entity)
static RemnantNexusIntel getNexusIntel(SectorEntityToken entity)
static SalvorsTallyIntel getSalvorsTallyIntel(StarSystemAPI system)
static boolean hasUnexploredRuins(MarketAPI market)
Definition Misc.java:5879
String getSpriteName(String category, String id)
Object getSpec(Class c, String id, boolean nullOnNotFound)
void addScript(EveryFrameScript script)
List< EveryFrameScript > getScripts()
void setDiscoverable(Boolean discoverable)
void addXP(long xp, TextPanelAPI textPanel, boolean withMessage, boolean allowBonusXP, boolean withLevelUp)
MutableCharacterStatsAPI getStats()