From 0623bdff066e53bec8bee3860f3b480a3a5cd050 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 29 Oct 2021 21:16:47 +0200 Subject: [PATCH] Adds HasVolatile functions to Angelscript Battle and BattleSide. --- .../TypeRegistry/Battling/RegisterBattleClass.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp index 1645a5e..ad2887a 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp @@ -84,6 +84,13 @@ static CScriptHandle BattleSide_AddVolatileWrapper(CreatureLib::Battling::Battle return handle; } +static bool Battle_HasVolatileWrapper(PkmnLib::Battling::Battle* obj, const ArbUt::StringView& name) { + return obj->HasVolatileScript(name); +} +static bool BattleSide_HasVolatileWrapper(CreatureLib::Battling::BattleSide* obj, const ArbUt::StringView& name) { + return obj->HasVolatileScript(name); +} + static u8 GetPokemonIndexWrapper(CreatureLib::Battling::BattleSide* obj, PkmnLib::Battling::Pokemon* pokemon) { return obj->GetCreatureIndex(pokemon); } @@ -120,6 +127,9 @@ void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) { asMETHODPR(CreatureLib::Battling::BattleSide, RemoveVolatileScript, (const ArbUt::BasicStringView&), void), asCALL_THISCALL); Ensure(r >= 0); + r = engine->RegisterObjectMethod("BattleSide", "bool HasVolatile(const constString &in name) const", + asFUNCTION(BattleSide_HasVolatileWrapper), asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); } void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) { @@ -169,4 +179,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Battle", "BattleParty@ FindPartyForPokemon(Pokemon@ pokemon)", asFUNCTION(FindPartyWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); + r = engine->RegisterObjectMethod("Battle", "bool HasVolatile(const constString &in name) const", + asFUNCTION(Battle_HasVolatileWrapper), asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); }