001package com.fs.starfarer.api.impl.campaign.procgen.themes;
002
003import com.fs.starfarer.api.Global;
004import com.fs.starfarer.api.impl.campaign.procgen.SalvageEntityGenDataSpec;
005
006public class SalvageEntityGeneratorOld {
007
008//      protected Constellation con;
009//      
010//      public SalvageEntityGeneratorOld(Constellation con) {
011//              this.con = con;
012//      }
013
014
015//      public void addSalvageableEntities() {
016//              
017//              Set<PlanetAPI> usedPlanets = new HashSet<PlanetAPI>();
018//              for (StarSystemAPI system : con.getSystems()) {
019//                      SectorEntityToken center = system.getCenter();
020//                      if (center == null) continue;
021//                      SectorEntityToken probe = addSalvageEntity(system, Entities.DERELICT_SURVEY_PROBE, Factions.DERELICT);
022//                      float orbitRadius = 4000;
023//                      float orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
024//                      probe.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f, 
025//                                                                                 4000, orbitDays, 10f, 20f);
026//                      
027//                      PlanetAPI planet = findInterestingPlanet(con, usedPlanets);
028//                      if (planet != null) {
029//                              DomainSurveyDerelictSpecialData special = new DomainSurveyDerelictSpecialData(SpecialType.PLANET_INTERESTING_PROPERTY);
030//                              special.type = SpecialType.PLANET_INTERESTING_PROPERTY;
031//                              special.type = SpecialType.PLANET_SURVEY_DATA;
032//                              special.entityId = planet.getId();
033//                              for (MarketConditionAPI mc : planet.getMarket().getConditions()) {
034//                                      if (interestingConditions.contains(mc.getId())) {
035//                                              special.secondaryId = mc.getId();
036//                                      }
037//                              }
038//                              usedPlanets.add(planet);
039//                              probe.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, special);
040//                      }
041//                      
042//                      
043//                      
044//                      SectorEntityToken ship = addSalvageEntity(system, Entities.DERELICT_SURVEY_SHIP, Factions.DERELICT);
045//                      orbitRadius = 5000;
046//                      orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
047//                      ship.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f, 
048//                                                                                 4000, orbitDays, 10f, 20f);
049//                      ship.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, new DomainSurveyDerelictSpecialData(SpecialType.SCRAMBLED));
050//                      
051//                      
052////                    DomainSurveyDerelictSpecialData special = new DomainSurveyDerelictSpecialData(SpecialType.PLANET_INTERESTING_PROPERTY);
053////                    special.type = SpecialType.LOCATION_SURVEY_SHIP;
054////                    special.entityId = ship.getId();
055////                    probe.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, special);
056//                      
057//                      
058//                      SectorEntityToken mothership = addSalvageEntity(system, Entities.DERELICT_MOTHERSHIP, Factions.DERELICT);
059//                      orbitRadius = 6000;
060//                      orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
061//                      mothership.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f, 
062//                                                                                 4000, orbitDays, 10f, 20f);
063//                      mothership.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, new DomainSurveyDerelictSpecialData(SpecialType.SCRAMBLED));
064//                      
065//                      //SectorEntityToken debris = addSalvageEntity(system, Entities.DEBRIS_FIELD, Factions.DERELICT);
066//                      //SectorEntityToken debris = system.addCustomEntity(null, null, Entities.DEBRIS_FIELD, Factions.NEUTRAL);
067////                    DebrisFieldParams params = new DebrisFieldParams(100f, 50f, 1f, 5f, 2f);
068////                    SectorEntityToken debris = system.addTerrain(Terrain.DEBRIS_FIELD, params);
069////                    orbitRadius = 6500;
070////                    orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
071////                    debris.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f, 
072////                                    4000, orbitDays, 10f, 20f);
073//              }
074//      }
075        
076        
077//      protected SectorEntityToken addSalvageEntity(StarSystemAPI system, String id, String faction) {
078//              SectorEntityToken entity = system.addCustomEntity(null, null, id, faction);
079//              
080//              SalvageEntityGenDataSpec spec = getSalvageSpec(id);
081//              
082//              switch (spec.getType()) {
083//              case ALWAYS_VISIBLE:
084//                      entity.setSensorProfile(null);
085//                      entity.setDiscoverable(null);
086//                      break;
087//              case DISCOVERABLE:
088//                      entity.setSensorProfile(1f);
089//                      entity.setDiscoverable(true);
090//                      break;
091//              case NOT_DISCOVERABLE:
092//                      entity.setSensorProfile(1f);
093//                      entity.setDiscoverable(false);
094//                      break;
095//              }
096//              
097//              long seed = StarSystemGenerator.random.nextLong();
098//              entity.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SEED, seed);
099//              
100//              //entity.getMemoryWithoutUpdate().set("$hasDefenders", true);
101//              
102//              entity.getDetectedRangeMod().modifyFlat("gen", spec.getDetectionRange());
103//              
104//              return entity;
105//      }
106        
107        
108        
109//      public static SalvageEntityGenDataSpec getSalvageSpec(SectorEntityToken entity) {
110//              String id = entity.getCustomEntityType();
111//              if (entity.getMemoryWithoutUpdate().contains(MemFlags.SALVAGE_SPEC_ID)) {
112//                      id = entity.getMemoryWithoutUpdate().getString(MemFlags.SALVAGE_SPEC_ID);
113//              }
114//              return getSalvageSpec(id);
115//      }
116        
117        public static SalvageEntityGenDataSpec getSalvageSpec(String id) {
118                SalvageEntityGenDataSpec spec = (SalvageEntityGenDataSpec) Global.getSettings().getSpec(SalvageEntityGenDataSpec.class, id, false);
119                return spec;
120        }
121        
122        public static boolean hasSalvageSpec(String id) {
123                SalvageEntityGenDataSpec spec = (SalvageEntityGenDataSpec) Global.getSettings().getSpec(SalvageEntityGenDataSpec.class, id, true);
124                return spec != null;
125        }
126        
127//      public static SalvageEntityGenDataSpec getSalvageSpec(String id, boolean nullOnNotFound) {
128//              SalvageEntityGenDataSpec spec = (SalvageEntityGenDataSpec) Global.getSettings().getSpec(SalvageEntityGenDataSpec.class, id, true);
129//              return spec;
130//      }
131        
132        
133
134//      public static Set<String> interestingConditions = new HashSet<String>();
135//      
136//      static {
137//              interestingConditions.add(Conditions.VOLATILES_PLENTIFUL);
138//              interestingConditions.add(Conditions.ORE_ULTRARICH);
139//              interestingConditions.add(Conditions.RARE_ORE_RICH);
140//              interestingConditions.add(Conditions.RARE_ORE_ULTRARICH);
141//              interestingConditions.add(Conditions.FARMLAND_BOUNTIFUL);
142//              interestingConditions.add(Conditions.FARMLAND_ADEQUATE);
143//              interestingConditions.add(Conditions.ORGANICS_PLENTIFUL);
144//              interestingConditions.add(Conditions.HABITABLE);
145//      }
146        
147//      public static PlanetAPI findInterestingPlanet(Constellation c, Set<PlanetAPI> exclude) {
148//              WeightedRandomPicker<PlanetAPI> planets = new WeightedRandomPicker<PlanetAPI>();
149//              
150//              for (StarSystemAPI system : c.getSystems()) {
151//                      for (PlanetAPI planet : system.getPlanets()) {
152//                              if (planet.isStar()) continue;
153//                              if (exclude.contains(planet)) continue;
154//                              if (planet.getMarket() == null || !planet.getMarket().isPlanetConditionMarketOnly()) continue;
155//                              //if (planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) continue;
156//                              for (MarketConditionAPI mc : planet.getMarket().getConditions()) {
157//                                      if (interestingConditions.contains(mc.getId())) {
158//                                              if (mc.getId().equals(Conditions.HABITABLE) && planet.getMarket().getHazardValue() > 0.25f) {
159//                                                      continue;
160//                                              }
161//                                              planets.add(planet);
162//                                              break;
163//                                      }
164//                              }
165//                      }
166//              }
167//              return planets.pick();
168//      }
169}
170
171
172
173
174
175
176
177
178
179
180
181
182
183