Add Held Item functions to AngelScript.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -60,7 +60,7 @@ CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) {
|
||||
asITypeInfo* t = engine->GetTypeInfoByDecl("array<uint8>");
|
||||
auto a = obj->GetTypes();
|
||||
CScriptArray* arr = CScriptArray::Create(t, a.size());
|
||||
for (size_t i = 0; i < a.size(); i++){
|
||||
for (size_t i = 0; i < a.size(); i++) {
|
||||
arr->SetValue(i, &a[i]);
|
||||
}
|
||||
return arr;
|
||||
@@ -75,7 +75,7 @@ CScriptArray* GetMoves(const PkmnLib::Battling::Pokemon* obj) {
|
||||
asITypeInfo* t = engine->GetTypeInfoByDecl("array<LearnedMove@>");
|
||||
auto a = obj->GetMoves();
|
||||
CScriptArray* arr = CScriptArray::Create(t, a.size());
|
||||
for (size_t i = 0; i < a.size(); i++){
|
||||
for (size_t i = 0; i < a.size(); i++) {
|
||||
arr->SetValue(i, &a[i]);
|
||||
}
|
||||
return arr;
|
||||
@@ -83,7 +83,6 @@ CScriptArray* GetMoves(const PkmnLib::Battling::Pokemon* obj) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
@@ -111,6 +110,17 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
r = engine->RegisterObjectMethod("Pokemon", "const Item@ get_HeldItem() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetHeldItem), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const string &in name) const",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, HasHeldItem), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const string &in name)",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem, (const std::string&), void),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const Item@ item)",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem, (const CreatureLib::Library::Item*), void),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "uint32 get_CurrentHealth() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetCurrentHealth), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
@@ -123,8 +133,8 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
r = engine->RegisterObjectMethod("Pokemon", "bool get_IsFainted() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, IsFainted), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "uint8[]@ GetTypes() const",
|
||||
asFUNCTION(GetTypes), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "uint8[]@ GetTypes() const", asFUNCTION(GetTypes),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "bool HasType(uint8 type) const",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, HasType), asCALL_THISCALL);
|
||||
@@ -135,14 +145,14 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void Damage(uint32 type, DamageSource source)",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, Damage), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void Heal(uint32 type)",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, Heal), asCALL_THISCALL);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void Heal(uint32 type)", asMETHOD(PkmnLib::Battling::Pokemon, Heal),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void OverrideActiveAbility(const string &in ability)",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, OverrideActiveTalent), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "LearnedMove@[]@ GetMoves() const",
|
||||
asFUNCTION(GetMoves), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "LearnedMove@[]@ GetMoves() const", asFUNCTION(GetMoves),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void ChangeStatBoost(Statistic stat, int8 amount)",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, ChangeStatBoost), asCALL_THISCALL);
|
||||
|
||||
Reference in New Issue
Block a user