53 public void generate(CharacterCreationData data, SectorGenProgress progress) {
58 boolean small =
"small".equals(data.getSectorSize());
59 StarAge sectorAge = data.getSectorAge();
60 if (sectorAge ==
null) {
68 boolean [][] cells =
new boolean [cellsWide][cellsHigh];
78 for (
int i = 0; i < cells.length; i++) {
79 for (
int j = 0; j < cells[0].length; j++) {
80 if (i <= hPad || j <= vPad || i >= cellsWide - hPad || j >= cellsHigh - vPad) {
88 int [] index =
getIndex(system.getLocation());
93 if (x > cellsWide - 1) x = cellsWide - 1;
94 if (y > cellsHigh - 1) y = cellsHigh - 1;
112 progress.render(
"Generating sector...", 0.1f);
116 List<Constellation> constellations =
new ArrayList<Constellation>();
117 for (
int k = 0; k < count; k++) {
118 WeightedRandomPicker<Pair<Integer, Integer>> picker =
new WeightedRandomPicker<Pair<Integer,Integer>>(
StarSystemGenerator.
random);
119 for (
int i = 0; i < cells.length; i++) {
120 for (
int j = 0; j < cells[0].length; j++) {
121 if (cells[i][j])
continue;
123 Pair<Integer, Integer> p =
new Pair<Integer, Integer>(i, j);
128 Pair<Integer, Integer> pick = picker.pick();
129 if (pick ==
null)
continue;
136 CustomConstellationParams params =
new CustomConstellationParams(
StarAge.
ANY);
137 if (!custom.isEmpty()) params = custom.remove(0);
152 age = agePicker.pick();
157 params.location =
new Vector2f(x, y);
159 constellations.add(c);
161 progress.render(
"Generating constellations...", 0.1f + 0.8f * (
float)k / (
float) count);
166 HyperspaceTerrainPlugin hyper = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
176 float angleOffset = random.nextFloat() * 360f;
177 editor.
clearArc(0f, 0f, w / 2f, w / 2f + 3000,
178 angleOffset + 0f, angleOffset + 360f * (2f + random.nextFloat() * 2f), 0.01f, 0.33f);
181 int numArcs = (int) (20f + 8f * random.nextFloat());
183 for (
int i = 0; i < numArcs; i++) {
184 float dist = w/2f + w/2f * random.nextFloat();
185 float angle = random.nextFloat() * 360f;
187 Vector2f dir = Misc.getUnitVectorAtDegreeAngle(angle);
188 dir.scale(dist - (w/12f + w/3f * random.nextFloat()));
192 float width = 800f * (1f + 2f * random.nextFloat());
194 float clearThreshold = 0f + 0.5f * random.nextFloat();
197 editor.
clearArc(dir.x, dir.y, dist - width/2f, dist + width/2f, 0, 360f, clearThreshold);
202 progress.render(
"Generating objects...", 0.9f);
205 ThemeGenContext context =
new ThemeGenContext();
206 context.constellations = constellations;
207 SectorThemeGenerator.generate(context);
209 progress.render(
"Finishing generation...", 1f);
270 List<CustomConstellationParams> result =
new ArrayList<CustomConstellationParams>();
272 for (StarSystemType type : EnumSet.allOf(StarSystemType.class)) {
273 if (type == StarSystemType.DEEP_SPACE || type == StarSystemType.DEEP_SPACE_GAS_GIANT)
continue;
274 CustomConstellationParams params =
new CustomConstellationParams(
StarAge.
ANY);
275 params.systemTypes.add(type);
276 if (type == StarSystemType.NEBULA) params.forceNebula =
true;
280 CustomConstellationParams params =
new CustomConstellationParams(
StarAge.
ANY);
281 params.starTypes.add(StarTypes.BLACK_HOLE);
284 params =
new CustomConstellationParams(
StarAge.
ANY);
285 params.starTypes.add(StarTypes.NEUTRON_STAR);