MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / placeInitialObjects

Method placeInitialObjects

source/game/StarSystemWorldServer.cpp:319–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319void 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
340void SystemWorldServer::spawnObjects() {
341 double diff = min(systemConfig().objectSpawnCycle, time() - m_lastSpawn);

Callers

nothing calls this directly

Calls 14

singletonClass · 0.85
staticRandomU64Function · 0.85
toStringFunction · 0.85
UuidClass · 0.85
CelestialCoordinateClass · 0.85
jsonMethod · 0.80
assetsMethod · 0.80
getArrayMethod · 0.80
toIntMethod · 0.80
toArrayMethod · 0.80
enterOrbitMethod · 0.80
selectMethod · 0.45

Tested by

no test coverage detected