18 if (context.lagrangeParent ==
null || context.lagrangePointType ==
null)
return null;
22 SectorEntityToken parent = context.center;
23 if (context.parent !=
null) parent = context.parent;
24 if (context.lagrangeParent !=
null) parent = context.center;
26 if (parent ==
null)
return null;
29 for (
int i = 5; i <= 11; i++) {
30 sizePicker.add(i, 20 - i);
33 int size = sizePicker.pick();
34 float radius = size * 100f;
36 float maxRadius = (context.currentRadius - parent.getRadius()) * 0.5f;
37 if (radius > maxRadius) radius = maxRadius;
38 if (radius < 400) radius = 400;
40 float area = radius * radius * 3.14f;
41 int count = (int) (area / 80000f);
42 if (count < 10) count = 10;
43 if (count > 100) count = 100;
46 StarSystemAPI system = context.system;
47 float orbitRadius = context.currentRadius + radius;
51 if (context.lagrangeParent !=
null) {
52 orbitRadius = context.lagrangeParent.orbitRadius;
53 orbitDays = context.lagrangeParent.orbitDays;
56 angle = context.lagrangeParent.orbitAngle + angleOffset;
59 SectorEntityToken field = system.addTerrain(Terrain.ASTEROID_FIELD,
60 new AsteroidFieldParams(
69 field.setCircularOrbit(parent, angle, orbitRadius, orbitDays);
73 float prevRadius = context.currentRadius;
74 WeightedRandomPicker<EntityGenDataSpec> picker = context.gen.getPickerForCategory(cat, context,
77 picker.print(
" Picking from category " + cat.
getCategory() +
78 ", orbit index " + (context.parent !=
null ? context.parentOrbitIndex : context.orbitIndex));
83 System.out.println(
" Nothing to pick");
86 System.out.println(
" Picked: " + pick.
getId());
93 context.currentRadius = orbitRadius;
95 GenResult result = context.gen.addPlanet(context, planetData,
true,
false);
96 if (result !=
null && !result.entities.isEmpty()) {
97 context.gen.getAllEntitiesAdded().put(result.entities.get(0), result.entities);
98 if (context.lagrangeParent !=
null && !result.entities.isEmpty()) {
99 context.gen.getLagrangeParentMap().put(result.entities.get(0), context.lagrangeParent.planet);
111 context.parentRadiusOverride = -1;
112 context.currentRadius = prevRadius;
116 GenResult result =
new GenResult();
117 result.onlyIncrementByWidth =
false;
118 result.orbitalWidth = radius * 2f;
119 result.entities.add(field);