#ifndef PKMNLIB_ANGELSCRIPRESOLVER_HPP #define PKMNLIB_ANGELSCRIPRESOLVER_HPP #include #include "../../Battling/Library/BattleLibrary.hpp" #define ANGELSCRIPT_DLL_LIBRARY_IMPORT #include #include #include "AngelScriptScript.hpp" #include "AngelScriptTypeInfo.hpp" class AngelScripResolver : public CreatureLib::Battling::ScriptResolver { private: asIScriptEngine* _engine = nullptr; asIScriptModule* _mainModule = nullptr; ContextPool* _contextPool = nullptr; const char* (*_loadFunc)(ScriptCategory category, const char*) = nullptr; std::unordered_map _types; static void MessageCallback(const asSMessageInfo* msg, void* param); static void Print(const std::string& str) { std::cout << str << std::endl; } AngelScriptTypeInfo* GetTypeInfo(const std::string& name); void RegisterTypes(); public: ~AngelScripResolver() override { delete _contextPool; for (const auto& type : _types) { delete type.second; } _types.clear(); _engine->ShutDownAndRelease(); } void Initialize(CreatureLib::Battling::BattleLibrary* library) override; void SetCreateFunction(const char* (*loadFunc)(ScriptCategory category, const char* scriptName)) { _loadFunc = loadFunc; } void CreateScript(ScriptCategory category, const char* scriptName); void FinalizeModule(); CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const std::string& scriptName) override; }; #endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP