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

Function constructSpawnProfile

source/game/StarSpawnTypeDatabase.cpp:95–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95SpawnProfile constructSpawnProfile(Json const& config, uint64_t seed) {
96 SpawnProfile spawnProfile;
97 auto commonGroups = Root::singleton().assets()->json("/spawning.config:spawnGroups");
98 for (auto group : config.get("groups", JsonArray()).iterateArray()) {
99 auto poolNameOrConfig = group.get("pool");
100 WeightedPool<String> typePool;
101 if (poolNameOrConfig.canConvert(Json::Type::String))
102 typePool = jsonToWeightedPool<String>(commonGroups.get(poolNameOrConfig.toString()));
103 else
104 typePool = jsonToWeightedPool<String>(poolNameOrConfig);
105
106 spawnProfile.spawnTypes.addAll(typePool.selectUniques(group.getUInt("select"), ++seed));
107 }
108
109 spawnProfile.monsterParameters = config.getObject("monsterParameters", JsonObject());
110
111 return spawnProfile;
112}
113
114SpawnTypeDatabase::SpawnTypeDatabase() {
115 auto assets = Root::singleton().assets();

Callers 1

createBiomeMethod · 0.85

Calls 11

singletonClass · 0.85
jsonMethod · 0.80
assetsMethod · 0.80
iterateArrayMethod · 0.80
canConvertMethod · 0.80
selectUniquesMethod · 0.80
getUIntMethod · 0.80
getMethod · 0.45
toStringMethod · 0.45
addAllMethod · 0.45
getObjectMethod · 0.45

Tested by

no test coverage detected