Adds helper function to add definition to the script library.

This commit is contained in:
Deukhoofd 2021-08-22 19:03:03 +02:00
parent f4364d23a6
commit 9b27ad72f1
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 6 additions and 1 deletions

View File

@ -14,7 +14,9 @@ class BuildLibrary {
static PkmnLib::Library::TimeOfDay GetTime() { return PkmnLib::Library::TimeOfDay::Morning; }
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* typesLibrary = BuildTypes::Build(path / "Types.csv");
auto* natureLibrary = BuildNatures::Build(path / "Natures.csv");
@ -41,6 +43,9 @@ public:
scriptResolver->Initialize(battleLib);
if (onScriptInitialize) {
onScriptInitialize(scriptResolver);
}
auto asScriptResolver = dynamic_cast<AngelScriptResolver*>(scriptResolver);
for (const auto& dirEntry : std::filesystem::recursive_directory_iterator(scriptsPath)) {