Starsector API
Loading...
Searching...
No Matches
SalvageEntityGeneratorOld.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.procgen.themes;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.impl.campaign.procgen.SalvageEntityGenDataSpec;
5
7
8// protected Constellation con;
9//
10// public SalvageEntityGeneratorOld(Constellation con) {
11// this.con = con;
12// }
13
14
15// public void addSalvageableEntities() {
16//
17// Set<PlanetAPI> usedPlanets = new HashSet<PlanetAPI>();
18// for (StarSystemAPI system : con.getSystems()) {
19// SectorEntityToken center = system.getCenter();
20// if (center == null) continue;
21// SectorEntityToken probe = addSalvageEntity(system, Entities.DERELICT_SURVEY_PROBE, Factions.DERELICT);
22// float orbitRadius = 4000;
23// float orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
24// probe.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f,
25// 4000, orbitDays, 10f, 20f);
26//
27// PlanetAPI planet = findInterestingPlanet(con, usedPlanets);
28// if (planet != null) {
29// DomainSurveyDerelictSpecialData special = new DomainSurveyDerelictSpecialData(SpecialType.PLANET_INTERESTING_PROPERTY);
30// special.type = SpecialType.PLANET_INTERESTING_PROPERTY;
31// special.type = SpecialType.PLANET_SURVEY_DATA;
32// special.entityId = planet.getId();
33// for (MarketConditionAPI mc : planet.getMarket().getConditions()) {
34// if (interestingConditions.contains(mc.getId())) {
35// special.secondaryId = mc.getId();
36// }
37// }
38// usedPlanets.add(planet);
39// probe.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, special);
40// }
41//
42//
43//
44// SectorEntityToken ship = addSalvageEntity(system, Entities.DERELICT_SURVEY_SHIP, Factions.DERELICT);
45// orbitRadius = 5000;
46// orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
47// ship.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f,
48// 4000, orbitDays, 10f, 20f);
49// ship.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, new DomainSurveyDerelictSpecialData(SpecialType.SCRAMBLED));
50//
51//
56//
57//
58// SectorEntityToken mothership = addSalvageEntity(system, Entities.DERELICT_MOTHERSHIP, Factions.DERELICT);
59// orbitRadius = 6000;
60// orbitDays = orbitRadius / (20f + StarSystemGenerator.random.nextFloat() * 5f);
61// mothership.setCircularOrbitWithSpin(center, StarSystemGenerator.random.nextFloat()* 360f,
62// 4000, orbitDays, 10f, 20f);
63// mothership.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SPECIAL_DATA, new DomainSurveyDerelictSpecialData(SpecialType.SCRAMBLED));
64//
65// //SectorEntityToken debris = addSalvageEntity(system, Entities.DEBRIS_FIELD, Factions.DERELICT);
66// //SectorEntityToken debris = system.addCustomEntity(null, null, Entities.DEBRIS_FIELD, Factions.NEUTRAL);
73// }
74// }
75
76
77// protected SectorEntityToken addSalvageEntity(StarSystemAPI system, String id, String faction) {
78// SectorEntityToken entity = system.addCustomEntity(null, null, id, faction);
79//
80// SalvageEntityGenDataSpec spec = getSalvageSpec(id);
81//
82// switch (spec.getType()) {
83// case ALWAYS_VISIBLE:
84// entity.setSensorProfile(null);
85// entity.setDiscoverable(null);
86// break;
87// case DISCOVERABLE:
88// entity.setSensorProfile(1f);
89// entity.setDiscoverable(true);
90// break;
91// case NOT_DISCOVERABLE:
92// entity.setSensorProfile(1f);
93// entity.setDiscoverable(false);
94// break;
95// }
96//
97// long seed = StarSystemGenerator.random.nextLong();
98// entity.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SEED, seed);
99//
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) {
119 return spec;
120 }
121
122 public static boolean hasSalvageSpec(String id) {
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
static SettingsAPI getSettings()
Definition Global.java:51
Object getSpec(Class c, String id, boolean nullOnNotFound)