| 317 | } |
| 318 | |
| 319 | void SystemWorldServer::placeInitialObjects() { |
| 320 | auto config = Root::singleton().assets()->json("/systemworld.config"); |
| 321 | RandomSource rand(staticRandomU64("SystemWorldGeneration", toString(m_location))); |
| 322 | |
| 323 | WeightedPool<JsonArray> spawnPools = jsonToWeightedPool<JsonArray>(config.getArray("initialObjectPools")); |
| 324 | JsonArray spawn = spawnPools.select(rand); |
| 325 | int count = spawn.get(0).toInt(); |
| 326 | if (count > 0) { |
| 327 | WeightedPool<String> objectPool = jsonToWeightedPool<String>(spawn.get(1).toArray()); |
| 328 | for (int i = 0; i < count; i++) { |
| 329 | Uuid uuid = Uuid(); |
| 330 | auto objectConfig = systemObjectConfig(objectPool.select(rand), uuid); |
| 331 | Vec2F position = randomObjectSpawnPosition(rand); |
| 332 | |
| 333 | auto object = make_shared<SystemObject>(objectConfig, uuid, position, time()); |
| 334 | object->enterOrbit(CelestialCoordinate(m_location), { 0.0, 0.0 }, time()); // orbit center of system |
| 335 | m_objects.set(uuid, object); |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | void SystemWorldServer::spawnObjects() { |
| 341 | double diff = min(systemConfig().objectSpawnCycle, time() - m_lastSpawn); |
nothing calls this directly
no test coverage detected