Adds helper function to add definition to the script library.
This commit is contained in:
parent
f4364d23a6
commit
9b27ad72f1
|
@ -14,7 +14,9 @@ class BuildLibrary {
|
||||||
static PkmnLib::Library::TimeOfDay GetTime() { return PkmnLib::Library::TimeOfDay::Morning; }
|
static PkmnLib::Library::TimeOfDay GetTime() { return PkmnLib::Library::TimeOfDay::Morning; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PkmnLib::Battling::BattleLibrary* Build(const std::string& pathString) {
|
static PkmnLib::Battling::BattleLibrary*
|
||||||
|
Build(const std::string& pathString,
|
||||||
|
std::function<void(PkmnLib::Battling::ScriptResolver*)> onScriptInitialize = {}) {
|
||||||
auto path = std::filesystem::path(pathString);
|
auto path = std::filesystem::path(pathString);
|
||||||
auto* typesLibrary = BuildTypes::Build(path / "Types.csv");
|
auto* typesLibrary = BuildTypes::Build(path / "Types.csv");
|
||||||
auto* natureLibrary = BuildNatures::Build(path / "Natures.csv");
|
auto* natureLibrary = BuildNatures::Build(path / "Natures.csv");
|
||||||
|
@ -41,6 +43,9 @@ public:
|
||||||
|
|
||||||
scriptResolver->Initialize(battleLib);
|
scriptResolver->Initialize(battleLib);
|
||||||
|
|
||||||
|
if (onScriptInitialize) {
|
||||||
|
onScriptInitialize(scriptResolver);
|
||||||
|
}
|
||||||
auto asScriptResolver = dynamic_cast<AngelScriptResolver*>(scriptResolver);
|
auto asScriptResolver = dynamic_cast<AngelScriptResolver*>(scriptResolver);
|
||||||
|
|
||||||
for (const auto& dirEntry : std::filesystem::recursive_directory_iterator(scriptsPath)) {
|
for (const auto& dirEntry : std::filesystem::recursive_directory_iterator(scriptsPath)) {
|
||||||
|
|
Loading…
Reference in New Issue