| 449 | } |
| 450 | |
| 451 | Maybe<pair<CelestialParameters, HashMap<int, CelestialPlanet>>> CelestialMasterDatabase::produceSystem( |
| 452 | RandomSource& random, Vec3I const& location) const { |
| 453 | float typeSelector = m_generationInformation.systemTypePerlin.get(location[0], location[1]); |
| 454 | String systemTypeName = binnedChoiceFromJson(m_generationInformation.systemTypeBins, typeSelector, "").toString(); |
| 455 | if (systemTypeName.empty()) |
| 456 | return {}; |
| 457 | auto systemType = m_generationInformation.systemTypes.get(systemTypeName); |
| 458 | |
| 459 | CelestialCoordinate systemCoordinate(location); |
| 460 | uint64_t systemSeed = random.randu64(); |
| 461 | |
| 462 | String prefix = m_generationInformation.systemPrefixNames.select(random); |
| 463 | String mid = m_generationInformation.systemNames.select(random); |
| 464 | String suffix = m_generationInformation.systemSuffixNames.select(random); |
| 465 | |
| 466 | String systemName = String(strf("{} {} {}", prefix, mid, suffix)).trim(); |
| 467 | |
| 468 | systemName = systemName.replace("<onedigit>", strf("{:01d}", random.randu32() % 10)); |
| 469 | systemName = systemName.replace("<twodigit>", strf("{:02d}", random.randu32() % 100)); |
| 470 | systemName = systemName.replace("<threedigit>", strf("{:03d}", random.randu32() % 1000)); |
| 471 | systemName = systemName.replace("<fourdigit>", strf("{:04d}", random.randu32() % 10000)); |
| 472 | |
| 473 | CelestialParameters systemParameters = CelestialParameters(systemCoordinate, |
| 474 | systemSeed, |
| 475 | systemName, |
| 476 | jsonMerge(systemType.baseParameters, random.randValueFrom(systemType.variationParameters))); |
| 477 | |
| 478 | List<int> planetaryOrbits; |
| 479 | for (int i = 1; i <= m_baseInformation.planetOrbitalLevels; ++i) { |
| 480 | if (auto systemOrbitRegion = orbitRegion(systemType.orbitRegions, i)) { |
| 481 | if (random.randf() <= systemOrbitRegion->bodyProbability) |
| 482 | planetaryOrbits.append(i); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | HashMap<int, CelestialPlanet> systemObjects; |
| 487 | for (auto planetPair : enumerateIterator(planetaryOrbits)) { |
| 488 | auto systemOrbitRegion = orbitRegion(systemType.orbitRegions, planetPair.first); |
| 489 | |
| 490 | auto planetaryTypeName = systemOrbitRegion->planetaryTypes.select(random); |
| 491 | if (m_generationInformation.planetaryTypes.contains(planetaryTypeName)) { |
| 492 | auto planetaryType = m_generationInformation.planetaryTypes.get(planetaryTypeName); |
| 493 | auto planetaryParameters = |
| 494 | jsonMerge(planetaryType.baseParameters, random.randValueFrom(planetaryType.variationParameters)); |
| 495 | |
| 496 | CelestialCoordinate planetCoordinate(location, planetPair.first); |
| 497 | uint64_t planetarySeed = random.randu64(); |
| 498 | String planetaryName = strf("{} {}", systemName, m_generationInformation.planetarySuffixes.at(planetPair.second)); |
| 499 | |
| 500 | CelestialPlanet planet; |
| 501 | planet.planetParameters = |
| 502 | CelestialParameters(planetCoordinate, planetarySeed, planetaryName, planetaryParameters); |
| 503 | |
| 504 | List<int> satelliteOrbits; |
| 505 | for (int i = 1; i <= m_baseInformation.satelliteOrbitalLevels; ++i) { |
| 506 | if (satelliteOrbits.size() < planetaryType.maxSatelliteCount |
| 507 | && random.randf() < planetaryType.satelliteProbability) |
| 508 | satelliteOrbits.append(i); |
nothing calls this directly
no test coverage detected