Initial support for item use scripts in angelscript.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
65
src/ScriptResolving/AngelScript/AngelScriptItemUseScript.cpp
Normal file
65
src/ScriptResolving/AngelScript/AngelScriptItemUseScript.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "AngelScriptItemUseScript.hpp"
|
||||
#include "AngelScriptResolver.hpp"
|
||||
|
||||
bool AngelScriptItemUseScript::IsItemUsable() const {
|
||||
if (!__IsItemUsable.Exists) {
|
||||
return CreatureLib::Battling::ItemUseScript::IsItemUsable();
|
||||
}
|
||||
bool res = false;
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__IsItemUsable.Function, _resolver->GetContextPool(), _scriptObject, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {},
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
|
||||
return res;
|
||||
}
|
||||
|
||||
bool AngelScriptItemUseScript::IsCreatureUseItem() const {
|
||||
if (!__IsPokemonUseItem.Exists) {
|
||||
return CreatureLib::Battling::ItemUseScript::IsCreatureUseItem();
|
||||
}
|
||||
bool res = false;
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__IsPokemonUseItem.Function, _resolver->GetContextPool(), _scriptObject, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {},
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
|
||||
return res;
|
||||
}
|
||||
bool AngelScriptItemUseScript::IsUseValidForCreature(CreatureLib::Battling::Creature* creature) const {
|
||||
if (!__IsPokemonUseItem.Exists) {
|
||||
return CreatureLib::Battling::ItemUseScript::IsUseValidForCreature(creature);
|
||||
}
|
||||
bool res = false;
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__IsPokemonUseItem.Function, _resolver->GetContextPool(), _scriptObject, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { ctx->SetArgObject(0, (void*)creature); },
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
|
||||
return res;
|
||||
}
|
||||
bool AngelScriptItemUseScript::IsHoldable() const {
|
||||
if (!__IsHoldable.Exists) {
|
||||
return CreatureLib::Battling::ItemUseScript::IsHoldable();
|
||||
}
|
||||
bool res = false;
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__IsHoldable.Function, _resolver->GetContextPool(), _scriptObject, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {},
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
|
||||
return res;
|
||||
}
|
||||
void AngelScriptItemUseScript::OnUse() const {
|
||||
if (!__OnUse.Exists) {
|
||||
CreatureLib::Battling::ItemUseScript::OnUse();
|
||||
}
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__OnUse.Function, _resolver->GetContextPool(), _scriptObject, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {}, [&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
}
|
||||
void AngelScriptItemUseScript::OnCreatureUse(CreatureLib::Battling::Creature* creature) const {
|
||||
if (!__OnPokemonUse.Exists) {
|
||||
CreatureLib::Battling::ItemUseScript::OnUse();
|
||||
}
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__OnPokemonUse.Function, _resolver->GetContextPool(), _scriptObject, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { ctx->SetArgObject(0, (void*)creature); },
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
}
|
||||
Reference in New Issue
Block a user