Reorganized files
This commit is contained in:
47
src/ScriptResolving/AngelScript/AngelScripResolver.hpp
Normal file
47
src/ScriptResolving/AngelScript/AngelScripResolver.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef PKMNLIB_ANGELSCRIPRESOLVER_HPP
|
||||
#define PKMNLIB_ANGELSCRIPRESOLVER_HPP
|
||||
|
||||
#include <Battling/ScriptHandling/ScriptResolver.hpp>
|
||||
#include "../../Battling/Library/BattleLibrary.hpp"
|
||||
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <angelscript.h>
|
||||
#include <iostream>
|
||||
#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)(const char*) = nullptr;
|
||||
std::unordered_map<std::string, AngelScriptTypeInfo*> _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)(const char* scriptName)) { _loadFunc = loadFunc; }
|
||||
|
||||
void CreateScript(const char* scriptName);
|
||||
|
||||
void FinalizeModule();
|
||||
|
||||
CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const std::string& scriptName) override;
|
||||
};
|
||||
#endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP
|
||||
Reference in New Issue
Block a user