Adds proper AddVolatile wrapper for battle.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
76053af77f
commit
4e215895b7
|
@ -1,8 +1,10 @@
|
|||
#include "RegisterBattleClass.hpp"
|
||||
#include <CreatureLib/Battling/Models/Battle.hpp>
|
||||
#include <CreatureLib/Battling/Models/BattleSide.hpp>
|
||||
#include "../../../../../extern/angelscript_addons/scripthandle/scripthandle.h"
|
||||
#include "../../../../Battling/Battle/Battle.hpp"
|
||||
#include "../../../../Battling/Pokemon/Pokemon.hpp"
|
||||
#include "../../AngelScriptResolver.hpp"
|
||||
#include "../../AngelScriptScript.hpp"
|
||||
#include "../HelperFile.hpp"
|
||||
|
||||
|
@ -52,9 +54,12 @@ CreatureLib::Battling::BattleSide* GetBattleSideWrapper(PkmnLib::Battling::Battl
|
|||
return battle->GetSides()[index];
|
||||
}
|
||||
|
||||
static asIScriptObject* AddVolatileWrapper(PkmnLib::Battling::Battle* obj, const ArbUt::StringView& name) {
|
||||
auto* scriptObject = (AngelScriptScript*)obj->AddVolatileScript(name);
|
||||
return scriptObject->GetRawAngelscriptObject();
|
||||
static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Battle* obj, const ArbUt::StringView& name) {
|
||||
auto handle = CScriptHandle();
|
||||
auto* resolver = static_cast<AngelScriptResolver*>(obj->GetLibrary()->GetScriptResolver().get());
|
||||
auto script = static_cast<AngelScriptScript*>(obj->AddVolatileScript(name))->GetRawAngelscriptObject();
|
||||
handle.Set(script, resolver->GetBaseType("PkmnScript"));
|
||||
return handle;
|
||||
}
|
||||
|
||||
static u8 GetPokemonIndexWrapper(CreatureLib::Battling::BattleSide* obj, PkmnLib::Battling::Pokemon* pokemon) {
|
||||
|
@ -90,7 +95,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("Battle", "ChoiceQueue@ get_TurnQueue() const property",
|
||||
asFUNCTION(GetCurrentTurnQueueWrapper), asCALL_CDECL_OBJFIRST);
|
||||
Ensure(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Battle", "ref@ AddVolatile(const constString &in name) const",
|
||||
r = engine->RegisterObjectMethod("Battle", "ref@ AddVolatile(const constString &in name)",
|
||||
asFUNCTION(AddVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
||||
Ensure(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
|
|
|
@ -94,7 +94,6 @@ static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const A
|
|||
auto handle = CScriptHandle();
|
||||
auto* resolver = static_cast<AngelScriptResolver*>(obj->GetLibrary()->GetScriptResolver().get());
|
||||
auto script = static_cast<AngelScriptScript*>(obj->AddVolatileScript(name))->GetRawAngelscriptObject();
|
||||
script->AddRef();
|
||||
handle.Set(script, resolver->GetBaseType("PkmnScript"));
|
||||
return handle;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue