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

Method randomMonster

source/game/StarMonsterDatabase.cpp:151–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151MonsterVariant MonsterDatabase::randomMonster(String const& typeName, Json const& uniqueParameters) const {
152 size_t seed;
153 if (auto seedConfig = uniqueParameters.opt("seed")) {
154 if (seedConfig->type() == Json::Type::String) {
155 seed = lexicalCast<uint64_t>(seedConfig->toString());
156 } else {
157 seed = seedConfig->toUInt();
158 }
159 } else {
160 seed = Random::randu64();
161 }
162
163 return monsterVariant(typeName, seed, uniqueParameters);
164}
165
166MonsterVariant MonsterDatabase::monsterVariant(String const& typeName, uint64_t seed, Json const& uniqueParameters) const {
167 MutexLocker locker(m_cacheMutex);

Callers 3

processActionMethod · 0.80
spawnMonsterMethod · 0.80
spawnMonsterMethod · 0.80

Calls 5

randu64Function · 0.85
toUIntMethod · 0.80
optMethod · 0.45
typeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected