From e39056d3d6901ef9d54ceb82af01c773369541e3 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 20 Nov 2021 10:48:46 +0100 Subject: [PATCH] Adds angelscript interface to get types of a Pokemon. --- .../TypeRegistry/Battling/RegisterPokemonClass.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index b1980e8..36239fc 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -70,6 +70,9 @@ static const ArbUt::StringView& GetActiveAbilityWrapper(PkmnLib::Battling::Pokem return p->GetActiveTalent()->GetName(); } +static size_t GetTypesLengthWrapper(PkmnLib::Battling::Pokemon* p) { return p->GetTypes().size(); } +static uint8_t GetTypeWrapper(PkmnLib::Battling::Pokemon* p, size_t index) { return p->GetTypes()[index]; } + static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& name) { auto handle = CScriptHandle(); auto* resolver = static_cast(obj->GetLibrary()->GetScriptResolver().get()); @@ -116,6 +119,12 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Pokemon", "const constString& get_ActiveAbility() const property", asFUNCTION(GetActiveAbilityWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); + r = engine->RegisterObjectMethod("Pokemon", "uint64 get_TypesLength() const property", + asFUNCTION(GetTypesLengthWrapper), asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); + r = engine->RegisterObjectMethod("Pokemon", "uint8 GetType(uint64 index) const", asFUNCTION(GetTypeWrapper), + asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "void set_Height(float value) property", asMETHOD(PkmnLib::Battling::Pokemon, SetHeight), asCALL_THISCALL);