C Interface for History.

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2020-08-14 17:24:12 +02:00
parent cb4765e0cc
commit 73f48eab7a
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 23 additions and 2 deletions

View File

@ -77,4 +77,5 @@ export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
export uint8_t CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
Try(p->RegisterEventListener(func);)
}
}
export const HistoryHolder* CreatureLib_Battle_GetHistory(Battle* p) { return &p->GetHistory(); }

View File

@ -0,0 +1,20 @@
#include "../../src/Battling/History/HistoryElements/AttackUseHistory.hpp"
#include "../../src/Battling/History/HistoryHolder.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export const HistoryElement* CreatureLib_HistoryHandler_GetTopElement(const HistoryHolder* p) {
return p->GetTopElement().GetRaw();
}
export const HistoryElement* CreatureLib_HistoryHandler_GetLastUsedAttack(const HistoryHolder* p) {
return p->GetLastUsedAttack().GetRaw();
}
export HistoryElementKind CreatureLib_HistoryElement_GetKind(const HistoryElement* p) { return p->GetKind(); }
export const HistoryElement* CreatureLib_HistoryElement_GetPrevious(const HistoryElement* p) {
return p->GetPrevious().GetRaw();
}
export const ExecutingAttack* CreatureLib_AttackUseHistory_GetAttack(const AttackUseHistory* p) {
return p->GetAttack().GetRaw();
}

View File

@ -17,7 +17,7 @@ namespace CreatureLib::Battling {
AttackUseHistory(const ExecutingAttack* attack) : _attack(attack) {}
HistoryElementKind GetKind() const noexcept override { return HistoryElementKind::AttackUse; }
ArbUt::BorrowedPtr<const ExecutingAttack> GetAttack() { return _attack; }
ArbUt::BorrowedPtr<const ExecutingAttack> GetAttack() const noexcept { return _attack; }
};
}