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

Method NpcDatabase

source/game/StarNpcDatabase.cpp:17–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace Star {
16
17NpcDatabase::NpcDatabase() {
18 auto assets = Root::singleton().assets();
19
20 auto& files = assets->scanExtension("npctype");
21 assets->queueJsons(files);
22 for (auto& file : files) {
23 try {
24 auto config = assets->json(file);
25 String typeName = config.getString("type");
26
27 if (m_npcTypes.contains(typeName))
28 throw NpcException(strf("Repeat npc type name '{}'", typeName));
29
30 m_npcTypes[typeName] = config;
31
32 } catch (StarException const& e) {
33 throw NpcException(strf("Error loading npc type '{}'", file), e);
34 }
35 }
36}
37
38NpcVariant NpcDatabase::generateNpcVariant(String const& species, String const& typeName, float level) const {
39 return generateNpcVariant(species, typeName, level, Random::randu64(), {});

Callers

nothing calls this directly

Calls 7

singletonClass · 0.85
strfFunction · 0.85
assetsMethod · 0.80
queueJsonsMethod · 0.80
jsonMethod · 0.80
getStringMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected