Adds angelscript interface to get types of a Pokemon.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-20 10:48:46 +01:00
parent 95457d9701
commit e39056d3d6
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 9 additions and 0 deletions

View File

@ -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<AngelScriptResolver*>(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);