This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

View 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);
}
}