001package com.fs.starfarer.api.impl;
002
003import java.util.ArrayList;
004import java.util.Collections;
005import java.util.List;
006import java.util.Map;
007
008import java.awt.Color;
009
010import com.fs.starfarer.api.Global;
011import com.fs.starfarer.api.campaign.FactionAPI;
012import com.fs.starfarer.api.campaign.PlanetAPI;
013import com.fs.starfarer.api.campaign.SectorEntityToken;
014import com.fs.starfarer.api.campaign.SpecialItemPlugin;
015import com.fs.starfarer.api.campaign.SpecialItemSpecAPI;
016import com.fs.starfarer.api.campaign.StarSystemAPI;
017import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
018import com.fs.starfarer.api.campaign.econ.MarketAPI;
019import com.fs.starfarer.api.campaign.econ.MarketAPI.SurveyLevel;
020import com.fs.starfarer.api.campaign.impl.items.GenericSpecialItemPlugin;
021import com.fs.starfarer.api.characters.MarketConditionSpecAPI;
022import com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry;
023import com.fs.starfarer.api.impl.campaign.econ.impl.Farming;
024import com.fs.starfarer.api.impl.campaign.econ.impl.InstallableItemEffect;
025import com.fs.starfarer.api.impl.campaign.econ.impl.ItemEffectsRepo;
026import com.fs.starfarer.api.impl.campaign.econ.impl.PopulationAndInfrastructure;
027import com.fs.starfarer.api.impl.campaign.ids.Conditions;
028import com.fs.starfarer.api.impl.campaign.ids.Items;
029import com.fs.starfarer.api.impl.campaign.ids.Tags;
030import com.fs.starfarer.api.impl.campaign.intel.misc.HypershuntIntel;
031import com.fs.starfarer.api.impl.campaign.procgen.ConditionGenDataSpec;
032import com.fs.starfarer.api.impl.codex.CodexDataV2;
033import com.fs.starfarer.api.ui.TooltipMakerAPI;
034import com.fs.starfarer.api.util.Misc;
035import com.fs.starfarer.api.util.Pair;
036
037public class PlanetSearchData {
038
039        public static List<PSToggleButtonRowData> GENERAL_FILTERS = new ArrayList<>();
040        public static List<ResourceDepositsData> RESOURCE_DEPOSITS = new ArrayList<>();
041        public static List<PlanetFilter> COLONY_ITEMS_AND_CONDITIONS = new ArrayList<>();
042        public static List<PSToggleButtonRowData> OTHER_FACTORS = new ArrayList<>();
043        
044        /**
045         * The accept() method needs to be FAST. Otherwise, may slow the game down when
046         * interacting with the planet list and there are lots of known planets.
047         *
048         */
049        public static interface PlanetFilter {
050                public boolean accept(SectorEntityToken entity, Map<String, String> params);
051                public boolean shouldShow();
052                default String getOtherFactorId() {
053                        return null;
054                }
055                default String getOtherFactorButtonText() {
056                        return null;
057                }
058                
059                public void createTooltip(TooltipMakerAPI info, float width, String param);
060                default float getTooltipWidth() {
061                        return 350f;
062                }
063                default boolean isTooltipExpandable() {
064                        return false;
065                }
066                default boolean hasTooltip() {
067                        return true;
068                }
069        }
070        
071        public static boolean conditionRequiresSurveying(String id) {
072                Object test = Global.getSettings().getSpec(ConditionGenDataSpec.class, id, true);
073                if (test instanceof ConditionGenDataSpec) {
074                        ConditionGenDataSpec spec = (ConditionGenDataSpec) test;
075                        return spec.isRequiresSurvey();
076                }
077                return false;
078        }
079        
080        public static class MarketConditionData implements PlanetFilter {
081                public String id;
082                public String conditionId;
083                public MarketConditionSpecAPI spec;
084                public boolean reqSurvey;
085                public MarketConditionData(String conditionId) {
086                        this.id = "ps_mc_" + conditionId;
087                        this.conditionId = conditionId;
088                        
089                        spec = Global.getSettings().getMarketConditionSpec(conditionId);
090                        reqSurvey = conditionRequiresSurveying(id);
091                }
092                
093                @Override
094                public boolean accept(SectorEntityToken entity, Map<String, String> params) {
095                        String selected = params.get(id);
096                        if (selected == null) return true;
097                        
098                        if (entity.getMarket() == null) return false;
099                        
100                        if (spec != null && reqSurvey && entity.getMarket().getSurveyLevel() != SurveyLevel.FULL) {
101                                return false;
102                        }
103                        if (spec != null && spec.isPlanetary() && 
104                                        (entity.getMarket().getSurveyLevel() == SurveyLevel.NONE || 
105                                        entity.getMarket().getSurveyLevel() == SurveyLevel.SEEN)) {
106                                return false;
107                        }
108                        
109                        return entity.getMarket().hasCondition(conditionId);
110                }
111
112                @Override
113                public void createTooltip(TooltipMakerAPI info, float width, String param) {
114                        float opad = 10f;
115                        info.addTitle(spec.getName());
116                        String name = spec.getName().toLowerCase();
117                        info.addPara("Require " + Misc.getAOrAnFor(name) + " " + name + " to be present.", opad);
118                        info.setCodexEntryId(CodexDataV2.getConditionEntryId(conditionId));
119                }
120
121                @Override
122                public boolean shouldShow() {
123                        return true;
124                }
125        }       
126        
127        public static class ColonyItemData implements PlanetFilter {
128                public String id;
129                public String itemId;
130                public SpecialItemSpecAPI item;
131                public ColonyItemData(String itemId) {
132                        this.id = "ps_item_" + itemId;
133                        this.itemId = itemId;
134                        
135                        item = Global.getSettings().getSpecialItemSpec(itemId);
136                }
137                
138                @Override
139                public boolean accept(SectorEntityToken entity, Map<String, String> params) {
140                        String selected = params.get(id);
141                        if (selected == null) return true;
142                        
143                        if (entity.getMarket() == null) return false;
144                        
145                        if (itemId.equals(Items.CORONAL_PORTAL)) {                      
146                                Pair<SectorEntityToken, Float> p = PopulationAndInfrastructure.getNearestCoronalTap(entity.getLocationInHyperspace(), false, true);
147                                if (p == null || p.two > ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS) return false;
148                                return true;
149                        }
150                        
151//                      if (entity.getMarket().getSurveyLevel() != SurveyLevel.FULL) {
152//                              return false;
153//                      }
154                        
155                        if (itemId.equals(Items.ORBITAL_FUSION_LAMP)) {
156                                for (String id : ItemEffectsRepo.FUSION_LAMP_CONDITIONS) {
157                                        if (entity.getMarket().hasCondition(id)) return true;
158                                }
159                                return false;
160                        }
161                        
162                        InstallableItemEffect effect = ItemEffectsRepo.ITEM_EFFECTS.get(itemId);
163                        
164                        BaseIndustry fake = new Farming(); // constructor does nothing much
165                        fake.setMarket(entity.getMarket());
166                        
167                        return effect.getUnmetRequirements(fake, true).isEmpty();
168                }
169
170                @Override
171                public boolean shouldShow() {
172                        if (itemId.equals(Items.CORONAL_PORTAL)) {
173                                for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(HypershuntIntel.class)) {
174                                        HypershuntIntel hypershunt = (HypershuntIntel) intel;
175                                        if (hypershunt.defendersDefeated()) return true;
176                                }
177                                return false;
178                        }
179                        return SharedUnlockData.get().isPlayerAwareOfSpecialItem(itemId);
180                }
181
182                @Override
183                public void createTooltip(TooltipMakerAPI info, float width, String param) {
184//                      float opad = 10f;
185//                      String name = item.getName().toLowerCase();
186//                      info.addPara("Require " + Misc.getAOrAnFor(name) + " " + name + " to be usable on the planet.", opad);
187                        
188                        SpecialItemPlugin plugin = item.getNewPluginInstance(null);
189                        if (plugin instanceof GenericSpecialItemPlugin) {
190                                ((GenericSpecialItemPlugin) plugin).setTooltipIsForPlanetSearch(true);
191                        }
192                        plugin.createTooltip(info, false, null, null);
193                        if (plugin instanceof GenericSpecialItemPlugin) {
194                                ((GenericSpecialItemPlugin) plugin).setTooltipIsForPlanetSearch(false);
195                        }
196                        
197                        info.setCodexEntryId(CodexDataV2.getItemEntryId(item.getId()));
198//                      InstallableItemEffect effect = ItemEffectsRepo.ITEM_EFFECTS.get(itemId);
199//                      effect.addItemDescription(industry, text, data, mode);
200                }
201                public float getTooltipWidth() {
202                        return item.getNewPluginInstance(null).getTooltipWidth();
203                }
204
205                @Override
206                public boolean isTooltipExpandable() {
207                        return item.getNewPluginInstance(null).isTooltipExpandable();
208                }
209        }
210        
211        
212        public static class ResourceDepositsData implements PlanetFilter {
213                public String id;
214                public String idAny;
215                public String idNone;
216                public String title;
217                public String iconNone = Global.getSettings().getSpriteName("intel", "planet_search_none");
218                public String iconAny = Global.getSettings().getSpriteName("intel", "planet_search_any");
219                public List<String> conditions = new ArrayList<>();
220                public ResourceDepositsData(String id, String title) {
221                        this.id = id;
222                        this.idAny = id + "_any";
223                        this.idNone = id + "_none";
224                        this.title = title;
225                }
226                
227                @Override
228                public boolean accept(SectorEntityToken entity, Map<String, String> params) {
229                        String selected = params.get(id);
230                        if (selected == null) return true; // invalid UI state
231                        
232                        if (idAny.equals(selected)) {
233                                return true;
234                        }
235                        if (entity.getMarket() == null) {
236                                return false;
237                        }
238                        
239                        MarketAPI market = entity.getMarket();
240                        if (market.getSurveyLevel() != SurveyLevel.FULL) {
241                                return false;
242                        }
243                        
244                        
245                        if (idNone.equals(selected)) {
246                                for (String cid : conditions) {
247                                        if (market.hasCondition(cid)) {
248                                                return false;
249                                        }
250                                }
251                                return true;
252                        } else {
253                                boolean foundAtLeastSelected = false;
254                                for (String cid : conditions) {
255                                        if (cid.equals(selected)) {
256                                                foundAtLeastSelected = true;
257                                        }
258                                        if (foundAtLeastSelected && market.hasCondition(cid)) {
259                                                return true;
260                                        }
261                                }
262                                return false;
263                        }
264                }
265
266                @Override
267                public boolean shouldShow() {
268                        return true;
269                }
270                
271                @Override
272                public void createTooltip(TooltipMakerAPI info, float width, String param) {
273                        float opad = 10f;
274                        if (param == idAny) {
275                                info.addTitle(title + " not required");
276                                info.addPara("Disregard the presence or absence of " + title.toLowerCase() + " on the planet, both are acceptable.", opad);
277                        } else if (param == idNone) {
278                                info.addTitle("No " + title.toLowerCase());
279                                info.addPara("Require that no " + title.toLowerCase() + " be present on the planet.", opad);
280                        } else if (conditions.contains(param)) {
281                                MarketConditionSpecAPI spec = Global.getSettings().getMarketConditionSpec(param);
282                                if (spec != null) {
283                                        info.addTitle(spec.getName());
284                                        info.addPara("Require " + spec.getName().toLowerCase() + " or better.", opad);
285                                        info.setCodexEntryId(CodexDataV2.getConditionEntryId(param));
286                                }
287                        }
288                }
289        }
290        
291        public static enum PSToggleButtonRowMode {
292                ANY,
293                ONE,
294        }
295        
296        public static class PSToggleButtonData {
297                public String id;
298                public String text;
299                public boolean defaultState = false;
300                //public float widthOverride;
301                public PSToggleButtonData(String id, String text, boolean defaultState) {
302                        this.id = id;
303                        this.text = text;
304                        this.defaultState = defaultState;
305                }
306        }
307        
308        public static class PSToggleButtonRowData implements PlanetFilter {
309                public String id;
310                public String title;
311                public PSToggleButtonRowMode mode;
312                public List<PSToggleButtonData> buttons = new ArrayList<>();
313                public float prevPad = 0f;
314                public PSToggleButtonRowData(String id, String title, PSToggleButtonRowMode mode) {
315                        this.id = id;
316                        this.title = title;
317                        this.mode = mode;
318                }
319                
320                public void add(String id, String text, boolean defaultState) {
321                        buttons.add(new PSToggleButtonData(id, text, defaultState));
322                }
323
324                @Override
325                public boolean accept(SectorEntityToken entity, Map<String, String> params) {
326                        return true;
327                }
328                
329                @Override
330                public boolean shouldShow() {
331                        return true;
332                }
333                
334                public void createTooltip(TooltipMakerAPI info, float width, String param) {
335                        
336                }
337        }
338        
339        static {
340                PSToggleButtonRowData type = new PSToggleButtonRowData("type", null, PSToggleButtonRowMode.ANY) {
341                        @Override
342                        public boolean accept(SectorEntityToken entity, Map<String, String> params) {
343                                if (params.containsKey("stars") && entity.isStar()) {
344                                        return true;
345                                }
346                                if (params.containsKey("gas_giants") && 
347                                                entity instanceof PlanetAPI && ((PlanetAPI)entity).isGasGiant()) { 
348                                        return true;
349                                }
350                                if (params.containsKey("planets") && !entity.isStar() && 
351                                                !(entity instanceof PlanetAPI && ((PlanetAPI)entity).isGasGiant())) {
352                                        return true;
353                                }
354                                return false;
355                        }
356                        @Override
357                        public void createTooltip(TooltipMakerAPI info, float width, String param) {
358                                float opad = 10f;
359                                if (param.equals("stars")) {
360                                        info.addTitle("Stars");
361                                        info.addPara("Show stars and black holes.", opad);
362                                } else if (param.equals("gas_giants")) {
363                                        info.addTitle("Gas giants");
364                                        info.addPara("Show gas giants.", opad);
365                                } else if (param.equals("planets")) {
366                                        info.addTitle("Planets");
367                                        info.addPara("Show non-gas-giant planets and stations.", opad);
368                                }
369                        }
370                        
371                };
372                type.add("stars", "Stars", false);
373                type.add("gas_giants", "Gas giants", true);
374                type.add("planets", "Planets", true);
375                
376                PSToggleButtonRowData populated = new PSToggleButtonRowData("populated", null, PSToggleButtonRowMode.ANY) {
377                        @Override
378                        public boolean accept(SectorEntityToken entity, Map<String, String> params) {
379                                boolean conditionMarketOnly = true;
380                                if (entity.getMarket() != null) {
381                                        conditionMarketOnly = entity.getMarket().isPlanetConditionMarketOnly();
382                                }
383                                if (params.containsKey("populated") && !conditionMarketOnly) {
384                                        return true;
385                                }
386                                if (params.containsKey("claimed") && conditionMarketOnly) {
387                                        FactionAPI claimedBy = Misc.getClaimingFaction(entity);
388                                        if (claimedBy != null) return true;
389                                }
390                                if (params.containsKey("unclaimed") && conditionMarketOnly) {
391                                        FactionAPI claimedBy = Misc.getClaimingFaction(entity);
392                                        if (claimedBy == null) return true;
393                                }
394                                return false;
395                        }
396                        @Override
397                        public void createTooltip(TooltipMakerAPI info, float width, String param) {
398                                float opad = 10f;
399                                if (param.equals("populated")) {
400                                        info.addTitle("Populated");
401                                        info.addPara("Show populated planets.", opad);
402                                } else if (param.equals("claimed")) {
403                                        info.addTitle("Claimed");
404                                        info.addPara("Show uninhabited planets that are in a system claimed by a faction.", opad);
405                                        info.addPara("Colonization is inadvisable.", opad);
406                                } else if (param.equals("unclaimed")) {
407                                        info.addTitle("Unclaimed");
408                                        info.addPara("Show uninhabited and unclaimed planets.", opad);
409                                }
410                        }
411                };
412                populated.add("populated", "Populated", false);
413                populated.add("claimed", "Claimed", false);
414                populated.add("unclaimed", "Unclaimed", true);
415                
416                PSToggleButtonRowData surveyed = new PSToggleButtonRowData("surveyed", null, PSToggleButtonRowMode.ANY) {
417                        @Override
418                        public boolean accept(SectorEntityToken entity, Map<String, String> params) {
419                                if (entity.getMarket() == null) {
420                                        if (entity.isStar()) return true;
421                                        return false;
422                                }
423                                if (params.containsKey("surveyed") && entity.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
424                                        return true;
425                                }
426                                if (params.containsKey("unsurveyed") && entity.getMarket().getSurveyLevel() != SurveyLevel.FULL) {
427                                        return true;
428                                }
429                                return false;
430                        }
431                        @Override
432                        public void createTooltip(TooltipMakerAPI info, float width, String param) {
433                                float opad = 10f;
434                                if (param.equals("surveyed")) {
435                                        info.addTitle("Surveyed");
436                                        info.addPara("Show fully surveyed planets.", opad);
437                                } else if (param.equals("unsurveyed")) {
438                                        info.addTitle("Unsurveyed");
439                                        info.addPara("Show planets that have not been fully surveyed.", opad);
440                                }
441                        }
442                };
443                surveyed.add("surveyed", "Surveyed", true);
444                surveyed.add("unsurveyed", "Unsurveyed", true);
445                
446                PSToggleButtonRowData hazard = new PSToggleButtonRowData("hazard", "Hazard rating", PSToggleButtonRowMode.ONE) {
447                        @Override
448                        public boolean accept(SectorEntityToken entity, Map<String, String> params) {
449                                if (entity.getMarket() == null) {
450                                        if (entity.isStar() && params.containsKey("haz_any")) return true;
451                                        return false;
452                                }
453                                
454                                if (entity.getMarket().getSurveyLevel() != SurveyLevel.FULL &&
455                                                !params.containsKey("haz_any")) {
456                                        return false;
457                                }
458                                
459                                float hazard = entity.getMarket().getHazardValue();
460                                hazard = Math.round(hazard * 100f) / 100f;
461                                
462                                float test = 1000000f;
463                                if (params.containsKey("haz_1")) test = 1f;
464                                if (params.containsKey("haz_2")) test = 1.5f;
465                                if (params.containsKey("haz_3")) test = 2f;
466                                
467                                return hazard <= test;
468                        }
469                        @Override
470                        public void createTooltip(TooltipMakerAPI info, float width, String param) {
471                                float opad = 10f;
472                                Color h = Misc.getHighlightColor();
473                                info.addTitle("Hazard rating");
474                                if (param.equals("haz_any")) {
475                                        info.addPara("Do not filter out any planets based on their hazard rating.", opad);
476                                } else {
477                                        String rating = "";
478                                        if (param.equals("haz_1")) {
479                                                rating = "100%";
480                                        } else if (param.equals("haz_2")) {
481                                                rating = "150%";
482                                        } else if (param.equals("haz_3")) {
483                                                rating = "200%";
484                                        }
485                                        info.addPara("Only show planets with a hazard rating of %s or lower.", opad, h, rating);
486                                }
487                        }
488                };
489                hazard.add("haz_any", "Any", true);
490                hazard.add("haz_1", "100%-", false);
491                hazard.add("haz_2", "150%-", false);
492                hazard.add("haz_3", "200%-", false);
493                hazard.prevPad = 7f; // added to default pad of 3f
494                
495                PSToggleButtonRowData stablePoints = new PSToggleButtonRowData("stable_locs", "Stable locations", PSToggleButtonRowMode.ONE) {
496                        @Override
497                        public boolean accept(SectorEntityToken entity, Map<String, String> params) {
498                                StarSystemAPI system = entity.getStarSystem();
499                                if (system == null) return false;
500                                
501                                String key = "$core_ps_stableLocations";
502                                int num = 0;
503                                if (system.getMemoryWithoutUpdate().contains(key)) {
504                                        num = system.getMemoryWithoutUpdate().getInt(key);
505                                } else {
506                                        num = Misc.getNumStableLocations(entity.getStarSystem());
507                                        system.getMemoryWithoutUpdate().set(key, num, 0f);
508                                }
509                                
510                                int test = 0;
511                                if (params.containsKey("stable_1")) test = 1;
512                                if (params.containsKey("stable_2")) test = 2;
513                                if (params.containsKey("stable_3")) test = 3;
514                                
515                                return num >= test;
516                        }
517                        @Override
518                        public void createTooltip(TooltipMakerAPI info, float width, String param) {
519                                float opad = 10f;
520                                Color h = Misc.getHighlightColor();
521                                info.addTitle("Stable locations");
522                                if (param.equals("stable_0")) {
523                                        info.addPara("Do not filter out any planets based on the number of stable locations in the star system they are in.", opad);
524                                } else {
525                                        String locs = "";
526                                        if (param.equals("stable_1")) {
527                                                locs = "1";
528                                        } else if (param.equals("stable_2")) {
529                                                locs = "2";
530                                        } else if (param.equals("stable_3")) {
531                                                locs = "3";
532                                        }
533                                        info.addPara("Only show planets with %s or more stable locations in the star system they're in,"
534                                                        + " including locations already in use by objectives or similar.", opad, h, locs);
535                                }
536                        }
537                };;
538                stablePoints.add("stable_0", "Any", true);
539                stablePoints.add("stable_1", "1+", false);
540                stablePoints.add("stable_2", "2+", false);
541                stablePoints.add("stable_3", "3+", false);
542                stablePoints.prevPad = 2f;
543                
544                
545                ResourceDepositsData ore = new ResourceDepositsData("ore", "Ore");
546                ore.conditions.add(Conditions.ORE_SPARSE);
547                ore.conditions.add(Conditions.ORE_MODERATE);
548                ore.conditions.add(Conditions.ORE_ABUNDANT);
549                ore.conditions.add(Conditions.ORE_RICH);
550                ore.conditions.add(Conditions.ORE_ULTRARICH);
551                
552                ResourceDepositsData rareOre = new ResourceDepositsData("rare_ore", "Transplutonic ore");
553                rareOre.conditions.add(Conditions.RARE_ORE_SPARSE);
554                rareOre.conditions.add(Conditions.RARE_ORE_MODERATE);
555                rareOre.conditions.add(Conditions.RARE_ORE_ABUNDANT);
556                rareOre.conditions.add(Conditions.RARE_ORE_RICH);
557                rareOre.conditions.add(Conditions.RARE_ORE_ULTRARICH);
558                
559                ResourceDepositsData volatiles = new ResourceDepositsData("volatiles", "Volatiles");
560                volatiles.conditions.add(Conditions.VOLATILES_TRACE);
561                volatiles.conditions.add(Conditions.VOLATILES_DIFFUSE);
562                volatiles.conditions.add(Conditions.VOLATILES_ABUNDANT);
563                volatiles.conditions.add(Conditions.VOLATILES_PLENTIFUL);
564                
565                ResourceDepositsData organics = new ResourceDepositsData("organics", "Organics");
566                organics.conditions.add(Conditions.ORGANICS_TRACE);
567                organics.conditions.add(Conditions.ORGANICS_COMMON);
568                organics.conditions.add(Conditions.ORGANICS_ABUNDANT);
569                organics.conditions.add(Conditions.ORGANICS_PLENTIFUL);
570                
571                ResourceDepositsData farmland = new ResourceDepositsData("farmland", "Farmland");
572                farmland.conditions.add(Conditions.FARMLAND_POOR);
573                farmland.conditions.add(Conditions.FARMLAND_ADEQUATE);
574                farmland.conditions.add(Conditions.FARMLAND_RICH);
575                farmland.conditions.add(Conditions.FARMLAND_BOUNTIFUL);
576                
577                ResourceDepositsData ruins = new ResourceDepositsData("ruins", "Ruins");
578                ruins.conditions.add(Conditions.RUINS_SCATTERED);
579                ruins.conditions.add(Conditions.RUINS_WIDESPREAD);
580                ruins.conditions.add(Conditions.RUINS_EXTENSIVE);
581                ruins.conditions.add(Conditions.RUINS_VAST);
582                
583                
584                ResourceDepositsData hab = new ResourceDepositsData("habitable", "Hab");
585                hab.conditions.add(Conditions.HABITABLE);
586                
587                ResourceDepositsData cold = new ResourceDepositsData("cold", "Cold");
588                cold.conditions.add(Conditions.COLD);
589                cold.conditions.add(Conditions.VERY_COLD);
590                
591                ResourceDepositsData heat = new ResourceDepositsData("heat", "Heat");
592                heat.conditions.add(Conditions.HOT);
593                heat.conditions.add(Conditions.VERY_HOT);
594                
595                ResourceDepositsData atmo = new ResourceDepositsData("atmo", "Atmo");
596                atmo.conditions.add(Conditions.NO_ATMOSPHERE);
597                
598                ResourceDepositsData weather = new ResourceDepositsData("weather", "Wthr");
599                weather.conditions.add(Conditions.EXTREME_WEATHER);
600                
601                ResourceDepositsData darkness = new ResourceDepositsData("darkness", "Dark");
602                darkness.conditions.add(Conditions.POOR_LIGHT);
603                darkness.conditions.add(Conditions.DARK);
604                
605                ResourceDepositsData tectonics = new ResourceDepositsData("tectonics", "Tect");
606                tectonics.conditions.add(Conditions.TECTONIC_ACTIVITY);
607                tectonics.conditions.add(Conditions.EXTREME_TECTONIC_ACTIVITY);
608                
609//              PSToggleButtonRowData cryosleeper = new PSToggleButtonRowData("cryosleeper", null, PSToggleButtonRowMode.ANY) {
610//                      @Override
611//                      public boolean accept(SectorEntityToken entity, Map<String, String> params) {
612//                              if (!params.containsKey("cryosleeper")) return true;
613//                              
614//                              if (entity.getMarket() == null) return false;
615//                              
616//                              Pair<SectorEntityToken, Float> p = Cryorevival.getNearestCryosleeper(entity.getLocationInHyperspace(), false);
617//                              if (p == null || p.two > Cryorevival.MAX_BONUS_DIST_LY) return false;
618//                              return true;
619//                      }
620//
621//                      @Override
622//                      public boolean shouldShow() {
623//                              return Global.getSector().getIntelManager().getIntelCount(CryosleeperIntel.class, true) > 0;
624//                      }
625//                      @Override
626//                      public void createTooltip(TooltipMakerAPI info, float width, String param) {
627//                              float opad = 10f;
628//                              Color h = Misc.getHighlightColor();
629//                              IndustrySpecAPI spec = Global.getSettings().getIndustrySpec(Industries.CRYOREVIVAL);
630//                              info.addTitle("Cryosleeper");
631//                              info.addPara("Only show planets within %s light-years of a Domain-era Cryosleeper. Colonies "
632//                                              + "within range can build a %s and benefit from hugely increased population growth.", 
633//                                              opad, h, "" + (int)Math.round(Cryorevival.MAX_BONUS_DIST_LY), spec.getName());
634//                      }
635//              };
636//              cryosleeper.add("cryosleeper", "Domain-era Cryosleeper within range", false);
637                
638                //This is a problem if the static block is triggered earlier (e.g. if a mod adds to it in its ModPlugin)
639                // thus: moving this to internal code when the filter is initialized
640                // can still add things to OTHER_FACTORS here if it's something that does not depend on the campaign instance.
641//              for (ColonyOtherFactorsListener curr : Global.getSector().getListenerManager().
642//                                                                                              getListeners(ColonyOtherFactorsListener.class)) {
643//                      if (!(curr instanceof PlanetFilter)) continue;
644//                      final PlanetFilter filter = (PlanetFilter) curr;
645//                      final String id = filter.getOtherFactorId();
646//                      if (id == null) continue;
647//                      
648//                      PSToggleButtonRowData data = new PSToggleButtonRowData(id, null, PSToggleButtonRowMode.ANY) {
649//                              @Override
650//                              public boolean accept(SectorEntityToken entity, Map<String, String> params) {
651//                                      return filter.accept(entity, params);
652//                              }
653//                              @Override
654//                              public boolean shouldShow() {
655//                                      return filter.shouldShow();
656//                              }
657//                              @Override
658//                              public void createTooltip(TooltipMakerAPI info, float width, String param) {
659//                                      filter.createTooltip(info, width, param);
660//                              }
661//                      };
662//                      data.add(id, filter.getOtherFactorButtonText(), false);
663//                      
664//                      OTHER_FACTORS.add(data);
665//              }
666
667// handling this using the Hypershunt Tap in the items section instead
668//              PSToggleButtonRowData hypershunt = new PSToggleButtonRowData("hypershunt", null, PSToggleButtonRowMode.ANY) {
669//                      @Override
670//                      public boolean accept(SectorEntityToken entity, Map<String, String> params) {
671//                              if (!params.containsKey("hypershunt")) return true;
672//                              
673//                              if (entity.getMarket() == null) return false;
674//                              
675//                              Pair<SectorEntityToken, Float> p = PopulationAndInfrastructure.getNearestCoronalTap(entity.getLocationInHyperspace(), false, true);
676//                              if (p == null || p.two > ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS) return false;
677//                              return true;
678//                      }
679//                      
680//                      @Override
681//                      public boolean shouldShow() {
682//                              for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(HypershuntIntel.class)) {
683//                                      HypershuntIntel hypershunt = (HypershuntIntel) intel;
684//                                      if (hypershunt.defendersDefeated()) return true;
685//                              }
686//                              return false;
687//                      }
688//                      
689//              };
690//              hypershunt.add("hypershunt", "Coronal Hypershunt within range", false);
691                
692                
693                GENERAL_FILTERS.add(type);
694                GENERAL_FILTERS.add(populated);
695                GENERAL_FILTERS.add(surveyed);
696                GENERAL_FILTERS.add(hazard);
697                GENERAL_FILTERS.add(stablePoints);
698                
699                RESOURCE_DEPOSITS.add(ore);
700                RESOURCE_DEPOSITS.add(rareOre);
701                RESOURCE_DEPOSITS.add(volatiles);
702                RESOURCE_DEPOSITS.add(organics);
703                RESOURCE_DEPOSITS.add(farmland);
704                RESOURCE_DEPOSITS.add(ruins);
705                
706                
707                List<SpecialItemSpecAPI> items = new ArrayList<>();
708                for (SpecialItemSpecAPI spec : Global.getSettings().getAllSpecialItemSpecs()) {
709                        if (spec.hasTag(Tags.PLANET_SEARCH)) {
710                                items.add(spec);
711                        }
712                }
713                Collections.sort(items, (s1, s2) -> s1.getName().compareTo(s2.getName()));
714                items.forEach(item -> COLONY_ITEMS_AND_CONDITIONS.add(new ColonyItemData(item.getId())));
715                
716                
717                List<MarketConditionSpecAPI> conditions = new ArrayList<>();
718                for (MarketConditionSpecAPI spec : Global.getSettings().getAllMarketConditionSpecs()) {
719                        if (spec.hasTag(Tags.PLANET_SEARCH)) {
720                                conditions.add(spec);
721                        }
722                }
723                Collections.sort(conditions, (c1, c2) -> c1.getName().compareTo(c2.getName()));
724                conditions.forEach(condition -> COLONY_ITEMS_AND_CONDITIONS.add(new MarketConditionData(condition.getId())));
725                
726                
727//              kinda torn on what I prefer; the below seems more readable and easier to change/put breakpoints in -am
728//              Collections.sort(items, new Comparator<SpecialItemSpecAPI>() {
729//                      @Override
730//                      public int compare(SpecialItemSpecAPI o1, SpecialItemSpecAPI o2) {
731//                              return o1.getName().compareTo(o2.getName());
732//                      }
733//              });
734//              for (SpecialItemSpecAPI item : items) {
735//                      COLONY_ITEMS.add(new ColonyItemData(item.getId()));
736//              }
737                
738                //COLONY_FACTORS.add(cryosleeper);
739//              COLONY_FACTORS.add(hypershunt);
740        }
741}
742
743
744
745
746
747
748
749
750
751