Register Item types for AngelScript.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
041bd998fa
commit
574776dbe0
|
@ -60,10 +60,8 @@ SET(FILE_SOURCE
|
|||
)
|
||||
if (SCRIPT_PROVIDER STREQUAL "angelscript")
|
||||
SET(FILE_SOURCE ${FILE_SOURCE}
|
||||
"src/AngelScript/AngelScripResolver.cpp"
|
||||
"src/AngelScript/AngelScripResolver.hpp"
|
||||
"src/AngelScript/TypeRegistry/RegisterPokemonTypes.cpp"
|
||||
"src/AngelScript/TypeRegistry/RegisterPokemonTypes.hpp"
|
||||
"src/AngelScript/*.cpp"
|
||||
"src/AngelScript/*.hpp"
|
||||
"extern/angelscript_addons/*.cpp"
|
||||
"extern/angelscript_addons/*.h"
|
||||
)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "AngelScripResolver.hpp"
|
||||
#include "TypeRegistry/RegisterPokemonTypes.hpp"
|
||||
#include "../../extern/angelscript_addons/scriptstdstring/scriptstdstring.h"
|
||||
#include "../../extern/angelscript_addons/scripthelper/scripthelper.h"
|
||||
#include "../../extern/angelscript_addons/scriptstdstring/scriptstdstring.h"
|
||||
#include "TypeRegistry/RegisterItemTypes.hpp"
|
||||
#include "TypeRegistry/RegisterPokemonTypes.hpp"
|
||||
|
||||
CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateScriptResolver(){
|
||||
return new AngelScripResolver();
|
||||
|
@ -26,6 +27,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* librar
|
|||
RegisterExceptionRoutines(_engine);
|
||||
|
||||
RegisterPokemonTypes::Register(_engine);
|
||||
RegisterItemTypes::Register(_engine);
|
||||
|
||||
_mainModule = _engine->GetModule("pkmn", asGM_ALWAYS_CREATE);
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
#include "RegisterItemTypes.hpp"
|
||||
#include <cassert>
|
||||
#include "../../Library/Items/Item.hpp"
|
||||
|
||||
void RegisterItemTypes::Register(asIScriptEngine* engine) {
|
||||
RegisterItemCategoryEnum(engine);
|
||||
RegisterBattleItemCategoryEnum(engine);
|
||||
RegisterItemType(engine);
|
||||
}
|
||||
|
||||
void RegisterItemTypes::RegisterItemCategoryEnum(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterEnum("ItemCategory");
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "Misc", (int)CreatureLib::Library::ItemCategory::MiscItem);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "Pokeball", (int)CreatureLib::Library::ItemCategory::CaptureDevice);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "Medicine", (int)CreatureLib::Library::ItemCategory::Medicine);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "Berry", (int)CreatureLib::Library::ItemCategory::Berry);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "TM", (int)CreatureLib::Library::ItemCategory::TM);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "VariantChanger", (int)CreatureLib::Library::ItemCategory::VariantChanger);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "KeyItem", (int)CreatureLib::Library::ItemCategory::KeyItem);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "Mail", (int)CreatureLib::Library::ItemCategory::Mail);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterEnum("BattleItemCategory");
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "None", (int)CreatureLib::Library::BattleItemCategory::None);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Healing", (int)CreatureLib::Library::BattleItemCategory::Healing);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "StatusHealing", (int)CreatureLib::Library::BattleItemCategory::StatusHealing);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "CaptureDevice", (int)CreatureLib::Library::BattleItemCategory::CaptureDevice);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Misc", (int)CreatureLib::Library::BattleItemCategory::MiscBattleItem);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Item", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "const string& get_Name() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetName), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "ItemCategory get_Category() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetCategory), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "BattleItemCategory get_BattleCategory() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetBattleCategory), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "int get_Price() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetPrice), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "bool HasFlag(const string &in flag) const",
|
||||
asMETHOD(PkmnLib::Library::Item, HasFlag), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef PKMNLIB_REGISTERITEMTYPES_HPP
|
||||
#define PKMNLIB_REGISTERITEMTYPES_HPP
|
||||
#include <angelscript.h>
|
||||
|
||||
class RegisterItemTypes {
|
||||
static void RegisterItemCategoryEnum(asIScriptEngine* engine);
|
||||
static void RegisterBattleItemCategoryEnum(asIScriptEngine* engine);
|
||||
static void RegisterItemType(asIScriptEngine* engine);
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
||||
#endif // PKMNLIB_REGISTERITEMTYPES_HPP
|
Loading…
Reference in New Issue