Adds Angelscript functions for getting a volatile script from a Battle or BattleSide.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
86ffe00b20
commit
6cc4206292
|
@ -75,6 +75,18 @@ static CScriptHandle Battle_AddVolatileWrapper(PkmnLib::Battling::Battle* obj, c
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CScriptHandle Battle_GetVolatileWrapper(PkmnLib::Battling::Battle* obj, const ArbUt::StringView& name) {
|
||||||
|
auto handle = CScriptHandle();
|
||||||
|
auto* resolver = static_cast<AngelScriptResolver*>(obj->GetLibrary()->GetScriptResolver().get());
|
||||||
|
auto* s = static_cast<AngelScriptScript*>(obj->GetVolatileScript(name).GetValue());
|
||||||
|
if (s == nullptr) {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
auto* script = s->GetRawAngelscriptObject();
|
||||||
|
handle.Set(script, resolver->GetBaseType("PkmnScript"));
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
static CScriptHandle BattleSide_AddVolatileWrapper(CreatureLib::Battling::BattleSide* obj,
|
static CScriptHandle BattleSide_AddVolatileWrapper(CreatureLib::Battling::BattleSide* obj,
|
||||||
const ArbUt::StringView& name) {
|
const ArbUt::StringView& name) {
|
||||||
auto handle = CScriptHandle();
|
auto handle = CScriptHandle();
|
||||||
|
@ -84,6 +96,19 @@ static CScriptHandle BattleSide_AddVolatileWrapper(CreatureLib::Battling::Battle
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CScriptHandle BattleSide_GetVolatileWrapper(CreatureLib::Battling::BattleSide* obj,
|
||||||
|
const ArbUt::StringView& name) {
|
||||||
|
auto handle = CScriptHandle();
|
||||||
|
auto* resolver = static_cast<AngelScriptResolver*>(obj->GetBattle()->GetLibrary()->GetScriptResolver().get());
|
||||||
|
auto* s = static_cast<AngelScriptScript*>(obj->GetVolatileScript(name).GetValue());
|
||||||
|
if (s == nullptr) {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
auto* script = s->GetRawAngelscriptObject();
|
||||||
|
handle.Set(script, resolver->GetBaseType("PkmnScript"));
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
static bool Battle_HasVolatileWrapper(PkmnLib::Battling::Battle* obj, const ArbUt::StringView& name) {
|
static bool Battle_HasVolatileWrapper(PkmnLib::Battling::Battle* obj, const ArbUt::StringView& name) {
|
||||||
return obj->HasVolatileScript(name);
|
return obj->HasVolatileScript(name);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +147,9 @@ void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
|
||||||
r = engine->RegisterObjectMethod("BattleSide", "ref@ AddVolatile(const constString &in name)",
|
r = engine->RegisterObjectMethod("BattleSide", "ref@ AddVolatile(const constString &in name)",
|
||||||
asFUNCTION(BattleSide_AddVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
asFUNCTION(BattleSide_AddVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("BattleSide", "ref@ GetVolatile(const constString &in name)",
|
||||||
|
asFUNCTION(BattleSide_GetVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod(
|
r = engine->RegisterObjectMethod(
|
||||||
"BattleSide", "void RemoveVolatile(const constString &in name) const",
|
"BattleSide", "void RemoveVolatile(const constString &in name) const",
|
||||||
asMETHODPR(CreatureLib::Battling::BattleSide, RemoveVolatileScript, (const ArbUt::BasicStringView&), void),
|
asMETHODPR(CreatureLib::Battling::BattleSide, RemoveVolatileScript, (const ArbUt::BasicStringView&), void),
|
||||||
|
@ -154,6 +182,9 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
||||||
r = engine->RegisterObjectMethod("Battle", "ref@ AddVolatile(const constString &in name)",
|
r = engine->RegisterObjectMethod("Battle", "ref@ AddVolatile(const constString &in name)",
|
||||||
asFUNCTION(Battle_AddVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
asFUNCTION(Battle_AddVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("Battle", "ref@ GetVolatile(const constString &in name)",
|
||||||
|
asFUNCTION(Battle_GetVolatileWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod(
|
r = engine->RegisterObjectMethod(
|
||||||
"Battle", "void RemoveVolatile(const constString &in name) const",
|
"Battle", "void RemoveVolatile(const constString &in name) const",
|
||||||
asMETHODPR(PkmnLib::Battling::Battle, RemoveVolatileScript, (const ArbUt::BasicStringView&), void),
|
asMETHODPR(PkmnLib::Battling::Battle, RemoveVolatileScript, (const ArbUt::BasicStringView&), void),
|
||||||
|
|
Loading…
Reference in New Issue