CreatureLib/CInterface/Battling/ExecutingAttack.cpp

60 lines
2.9 KiB
C++

#include "../../src/Battling/Models/ExecutingAttack.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export_func u8 CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
size_t targetCount, u8 numberHits, Creature* user,
LearnedAttack* attack,
CreatureLib::Library::AttackData* attackData,
BattleScript* script) {
Try({
auto ls = ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>(targetCount);
for (size_t i = 0; i < targetCount; i++) {
ls.Append(targets[i]);
}
out = new ExecutingAttack(ls, numberHits, user, attack, attackData, script);
})
}
export_func void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
SIMPLE_GET_FUNC(ExecutingAttack, GetNumberOfHits, u8);
export_func u8 CreatureLib_ExecutingAttack_GetHitData(ExecutingAttack::HitData*& out, ExecutingAttack* p,
Creature* target, u8 hit) {
Try(out = &p->GetHitData(target, hit);)
}
export_func bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
return p->IsCreatureTarget(target);
}
export_func u8 CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
export_func const Creature* const* CreatureLib_ExecutingAttack_GetTargets(ExecutingAttack* p) {
return reinterpret_cast<const Creature* const*>(p->GetTargets().RawData());
}
export_func Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
export_func LearnedAttack* CreatureLib_ExecutingAttack_GetAttack(ExecutingAttack* p) { return p->GetAttack().GetRaw(); }
export_func const CreatureLib::Library::AttackData* CreatureLib_ExecutingAttack_GetUseAttack(ExecutingAttack* p) {
return p->GetUseAttack().GetRaw();
}
#define HITDATA_GET_FUNC(name, returnType) \
export_func returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
HITDATA_GET_FUNC(IsCritical, bool);
HITDATA_GET_FUNC(GetBasePower, u8);
HITDATA_GET_FUNC(GetEffectiveness, float);
HITDATA_GET_FUNC(GetDamage, u32);
HITDATA_GET_FUNC(GetType, u8);
#define HITDATA_SET_FUNC(name, type) \
export_func void CreatureLib_HitData##_##name(ExecutingAttack::HitData* p, type val) { p->name(val); }
HITDATA_SET_FUNC(SetCritical, bool);
HITDATA_SET_FUNC(SetBasePower, u8);
HITDATA_SET_FUNC(SetEffectiveness, float);
HITDATA_SET_FUNC(SetDamage, u32);
HITDATA_SET_FUNC(SetType, u8);
#undef HITDATA_GET_FUNC
#undef HITDATA_SET_FUNC