Adds Angelscript registration for AttemptCapture
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c0e7f905a9
commit
da5fe90601
|
@ -80,10 +80,10 @@ shared abstract class PkmnScript {
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
r = engine->GetModuleByIndex(0)->AddScriptSection("ItemUseScript", R"(
|
r = engine->GetModuleByIndex(0)->AddScriptSection("ItemUseScript", R"(
|
||||||
shared abstract class ItemUseScript {
|
shared abstract class ItemUseScript {
|
||||||
private Item@ __owner;
|
private const Item@ __owner;
|
||||||
|
|
||||||
protected const Item@ GetOwner() { return __owner; };
|
protected const Item@ GetOwner() { return __owner; };
|
||||||
protected void SetOwner(Item@ o) { @__owner = @o; };
|
protected void SetOwner(const Item@ o) { @__owner = @o; };
|
||||||
|
|
||||||
void OnInitialize(const narray<EffectParameter@>@ parameters){};
|
void OnInitialize(const narray<EffectParameter@>@ parameters){};
|
||||||
bool IsItemUsable() { return false; };
|
bool IsItemUsable() { return false; };
|
||||||
|
|
|
@ -74,10 +74,12 @@ static size_t GetTypesLengthWrapper(PkmnLib::Battling::Pokemon* p) { return p->G
|
||||||
static uint8_t GetTypeWrapper(PkmnLib::Battling::Pokemon* p, size_t index) { return p->GetTypes()[index]; }
|
static uint8_t GetTypeWrapper(PkmnLib::Battling::Pokemon* p, size_t index) { return p->GetTypes()[index]; }
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
// Angelscript aligns this wrong (aligned on 4 bytes, wants 8). While this is a slight performance hit, we can ignore it for now.
|
// Angelscript aligns this wrong (aligned on 4 bytes, wants 8). While this is a slight performance hit, we can ignore it
|
||||||
|
// for now.
|
||||||
[[clang::no_sanitize("alignment")]]
|
[[clang::no_sanitize("alignment")]]
|
||||||
#endif
|
#endif
|
||||||
static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& name) {
|
static CScriptHandle
|
||||||
|
AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& name) {
|
||||||
auto* resolver = static_cast<AngelScriptResolver*>(obj->GetLibrary()->GetScriptResolver().get());
|
auto* resolver = static_cast<AngelScriptResolver*>(obj->GetLibrary()->GetScriptResolver().get());
|
||||||
auto* script = static_cast<AngelScriptScript*>(obj->AddVolatileScript(name))->GetRawAngelscriptObject();
|
auto* script = static_cast<AngelScriptScript*>(obj->AddVolatileScript(name))->GetRawAngelscriptObject();
|
||||||
|
|
||||||
|
@ -213,6 +215,9 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
"Pokemon", "void ChangeForme(const constString &in name)",
|
"Pokemon", "void ChangeForme(const constString &in name)",
|
||||||
asMETHODPR(PkmnLib::Battling::Pokemon, ChangeVariant, (const ArbUt::StringView&), void), asCALL_THISCALL);
|
asMETHODPR(PkmnLib::Battling::Pokemon, ChangeVariant, (const ArbUt::StringView&), void), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("Pokemon", "void AttemptCapture(const Item@ item)",
|
||||||
|
asMETHOD(PkmnLib::Battling::Pokemon, AttemptCapture), asCALL_THISCALL);
|
||||||
|
Ensure(r >= 0);
|
||||||
|
|
||||||
r = engine->RegisterObjectMethod("TypeLibrary",
|
r = engine->RegisterObjectMethod("TypeLibrary",
|
||||||
"float GetEffectiveness(uint8 attackingType, Pokemon@ defender) const",
|
"float GetEffectiveness(uint8 attackingType, Pokemon@ defender) const",
|
||||||
|
|
Loading…
Reference in New Issue