Register Move Library in AngelScript.

This commit is contained in:
Deukhoofd 2020-01-13 20:02:28 +01:00
parent 1573720e97
commit dbc8aa2675
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 11 additions and 0 deletions

View File

@ -1,11 +1,13 @@
#include "RegisterMoveTypes.hpp"
#include <cassert>
#include "../../../Library/Moves/MoveData.hpp"
#include "../../../Library/Moves/MoveLibrary.hpp"
void RegisterMoveTypes::Register(asIScriptEngine* engine) {
RegisterMoveCategory(engine);
RegisterMoveTarget(engine);
RegisterMoveType(engine);
RegisterMoveLibrary(engine);
}
#define REGISTER_ENUM_VALUE(asName, cName, valueName) \
@ -68,5 +70,13 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) {
asMETHOD(PkmnLib::Library::MoveData, HasFlag), asCALL_THISCALL);
assert(r >= 0);
}
void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("MoveLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ GetMove(const string &in flag) const",
asMETHOD(PkmnLib::Library::MoveLibrary, GetMove), asCALL_THISCALL);
assert(r >= 0);
}
#undef REGISTER_ENUM_VALUE

View File

@ -6,6 +6,7 @@ class RegisterMoveTypes {
static void RegisterMoveCategory(asIScriptEngine* engine);
static void RegisterMoveTarget(asIScriptEngine* engine);
static void RegisterMoveType(asIScriptEngine* engine);
static void RegisterMoveLibrary(asIScriptEngine* engine);
public:
static void Register(asIScriptEngine* engine);
};