Adds get function to angelscript to get a pokemon at index.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-08-23 21:40:20 +02:00
parent e320e32226
commit 7fcc4a63c5
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 7 additions and 0 deletions

View File

@ -77,6 +77,10 @@ static u8 GetPokemonIndexWrapper(CreatureLib::Battling::BattleSide* obj, PkmnLib
return obj->GetCreatureIndex(pokemon); return obj->GetCreatureIndex(pokemon);
} }
static PkmnLib::Battling::Pokemon* GetPokemonWrapper(CreatureLib::Battling::BattleSide* obj, u8 index) {
return dynamic_cast<PkmnLib::Battling::Pokemon*>(obj->GetCreature(index).GetValue());
}
void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) { void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
int r = engine->RegisterObjectMethod( int r = engine->RegisterObjectMethod(
"BattleSide", "bool SwapPositions(uint8 a, uint8 b)", "BattleSide", "bool SwapPositions(uint8 a, uint8 b)",
@ -88,6 +92,9 @@ void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
r = engine->RegisterObjectMethod("BattleSide", "uint8 GetPokemonIndex(const Pokemon@ pokemon) const", r = engine->RegisterObjectMethod("BattleSide", "uint8 GetPokemonIndex(const Pokemon@ pokemon) const",
asFUNCTION(GetPokemonIndexWrapper), asCALL_CDECL_OBJFIRST); asFUNCTION(GetPokemonIndexWrapper), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0); Ensure(r >= 0);
r = engine->RegisterObjectMethod("BattleSide", "Pokemon@ GetPokemon(uint8 index) const",
asFUNCTION(GetPokemonWrapper), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
} }
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) { void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {