Register Item Library in AngelScript.

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

View File

@ -1,11 +1,13 @@
#include "RegisterItemTypes.hpp"
#include <cassert>
#include "../../../Library/Items/Item.hpp"
#include "../../../Library/Items/ItemLibrary.hpp"
void RegisterItemTypes::Register(asIScriptEngine* engine) {
RegisterItemCategoryEnum(engine);
RegisterBattleItemCategoryEnum(engine);
RegisterItemType(engine);
RegisterItemLibrary(engine);
}
void RegisterItemTypes::RegisterItemCategoryEnum(asIScriptEngine* engine) {
@ -65,3 +67,10 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
}
void RegisterItemTypes::RegisterItemLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("ItemLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("ItemLibrary", "const Item@ GetItem(const string &in name) const",
asMETHOD(PkmnLib::Library::ItemLibrary, GetItem), asCALL_THISCALL);
assert(r >= 0);
}

View File

@ -6,6 +6,7 @@ class RegisterItemTypes {
static void RegisterItemCategoryEnum(asIScriptEngine* engine);
static void RegisterBattleItemCategoryEnum(asIScriptEngine* engine);
static void RegisterItemType(asIScriptEngine* engine);
static void RegisterItemLibrary(asIScriptEngine* engine);
public:
static void Register(asIScriptEngine* engine);
};