v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
35
source/game/StarStagehandDatabase.cpp
Normal file
35
source/game/StarStagehandDatabase.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "StarStagehandDatabase.hpp"
|
||||
#include "StarStagehand.hpp"
|
||||
#include "StarJsonExtra.hpp"
|
||||
#include "StarRoot.hpp"
|
||||
#include "StarAssets.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
StagehandDatabase::StagehandDatabase() {
|
||||
auto assets = Root::singleton().assets();
|
||||
auto files = assets->scanExtension("stagehand");
|
||||
assets->queueJsons(files);
|
||||
for (auto file : files) {
|
||||
try {
|
||||
auto config = assets->json(file);
|
||||
|
||||
String typeName = config.getString("type");
|
||||
|
||||
if (m_stagehandTypes.contains(typeName))
|
||||
throw StagehandDatabaseException(strf("Repeat stagehand type name '%s'", typeName));
|
||||
|
||||
m_stagehandTypes[typeName] = config;
|
||||
|
||||
} catch (StarException const& e) {
|
||||
throw StagehandDatabaseException(strf("Error loading stagehand type '%s'", file), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StagehandPtr StagehandDatabase::createStagehand(String const& stagehandType, Json const& extraConfig) const {
|
||||
auto finalConfig = jsonMerge(m_stagehandTypes.get(stagehandType), extraConfig);
|
||||
return make_shared<Stagehand>(finalConfig);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue