|
|
|
|
@@ -0,0 +1,68 @@
|
|
|
|
|
#include "RegisterBattleHistory.hpp"
|
|
|
|
|
#include <CreatureLib/Battling/History/HistoryElements/AttackUseHistory.hpp>
|
|
|
|
|
#include <CreatureLib/Battling/History/HistoryElements/DamageHistory.hpp>
|
|
|
|
|
#include <CreatureLib/Battling/History/HistoryElements/HistoryElement.hpp>
|
|
|
|
|
#include "../HelperFile.hpp"
|
|
|
|
|
#include "../RefCast.hpp"
|
|
|
|
|
#include "CreatureLib/Battling/History/HistoryHolder.hpp"
|
|
|
|
|
|
|
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
|
|
|
|
|
|
void RegisterBattleHistory::Register(asIScriptEngine* engine) {
|
|
|
|
|
REGISTER_ENUM(HistoryElementKind, "HistoryElementKind");
|
|
|
|
|
|
|
|
|
|
RegisterHistoryElement(engine);
|
|
|
|
|
RegisterHistoryHolder(engine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T> void RegisterHistoryElementType(asIScriptEngine* engine, const std::string& type) {
|
|
|
|
|
Ensure(engine->RegisterObjectType(type.c_str(), 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
|
|
|
|
|
RegisterGetter<HistoryElement, ArbUt::OptionalBorrowedPtr<HistoryElement>, &HistoryElement::GetPrevious>(
|
|
|
|
|
engine, type.c_str(), "const HistoryElement@ get_Previous() const property");
|
|
|
|
|
RegisterGetter<HistoryElement, HistoryElementKind, &HistoryElement::GetKind>(
|
|
|
|
|
engine, type.c_str(), "HistoryElementKind get_Kind() const property");
|
|
|
|
|
RegisterGetter<HistoryElement, u32, &HistoryElement::GetTurnNumber>(engine, type.c_str(),
|
|
|
|
|
"uint32 get_TurnNumber() const property");
|
|
|
|
|
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("HistoryElement", ("const " + type + "@opCast() const").c_str(),
|
|
|
|
|
asFUNCTION((refCast<CreatureLib::Battling::HistoryElement, T>)),
|
|
|
|
|
asCALL_CDECL_OBJLAST) >= 0);
|
|
|
|
|
Ensure(engine->RegisterObjectMethod(type.c_str(), "const HistoryElement@ opImplCast() const",
|
|
|
|
|
asFUNCTION((refCast<T, CreatureLib::Battling::HistoryElement>)),
|
|
|
|
|
asCALL_CDECL_OBJLAST))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BORROWED_PTR_GETTER_FUNC(DamageHistory, Creature, GetTarget);
|
|
|
|
|
BORROWED_PTR_GETTER_FUNC(AttackUseHistory, const ExecutingAttack, GetAttack);
|
|
|
|
|
|
|
|
|
|
void RegisterBattleHistory::RegisterHistoryElement(asIScriptEngine* engine) {
|
|
|
|
|
Ensure(engine->RegisterObjectType("HistoryElement", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
|
|
|
|
|
RegisterHistoryElementType<DamageHistory>(engine, "DamageHistory");
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("DamageHistory", "Pokemon@ get_Target() const property",
|
|
|
|
|
asFunctionPtr(GetTargetWrapper), asCALL_CDECL_OBJFIRST) >= 0);
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("DamageHistory", "uint get_Amount() const property",
|
|
|
|
|
asMETHOD(DamageHistory, GetAmount), asCALL_THISCALL) >= 0);
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("DamageHistory", "DamageSource get_Source() const property",
|
|
|
|
|
asMETHOD(DamageHistory, GetDamageSource), asCALL_THISCALL) >= 0);
|
|
|
|
|
|
|
|
|
|
RegisterHistoryElementType<AttackUseHistory>(engine, "AttackUseHistory");
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("AttackUseHistory", "const ExecutingMove@ get_Move() const property",
|
|
|
|
|
asFunctionPtr(GetAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OPTIONAL_BORROWED_PTR_GETTER_FUNC(HistoryHolder, const HistoryElement, GetLastUsedAttack);
|
|
|
|
|
|
|
|
|
|
const HistoryElement* GetLastDamageOnTargetWrapper(const HistoryHolder* holder, const Creature* c) {
|
|
|
|
|
return holder->GetLastDamageOnTarget(c).GetValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RegisterBattleHistory::RegisterHistoryHolder(asIScriptEngine* engine) {
|
|
|
|
|
Ensure(engine->RegisterObjectType("BattleHistory", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
|
|
|
|
|
REGISTER_GETTER("BattleHistory", "const HistoryElement@ get_TopElement() const property", HistoryHolder,
|
|
|
|
|
GetTopElement);
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("BattleHistory", "const AttackUseHistory@ GetLastUsedAttack() const",
|
|
|
|
|
asFunctionPtr(GetLastUsedAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0);
|
|
|
|
|
Ensure(engine->RegisterObjectMethod("BattleHistory",
|
|
|
|
|
"const DamageHistory@ GetLastDamageOnTarget(Pokemon@ target) const",
|
|
|
|
|
asFunctionPtr(GetLastDamageOnTargetWrapper), asCALL_CDECL_OBJFIRST) >= 0);
|
|
|
|
|
}
|