Adds support for History data, allowing us to store specific interesting occurrences in the data flow, and recall them later.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
24
src/Battling/History/HistoryElements/AttackUseHistory.hpp
Normal file
24
src/Battling/History/HistoryElements/AttackUseHistory.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef CREATURELIB_ATTACKUSEHISTORY_HPP
|
||||
#define CREATURELIB_ATTACKUSEHISTORY_HPP
|
||||
#include "../../Models/ExecutingAttack.hpp"
|
||||
#include "HistoryElement.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class AttackUseHistory : public HistoryElement {
|
||||
std::unique_ptr<const ExecutingAttack> _attack;
|
||||
|
||||
protected:
|
||||
void Clear() override {
|
||||
_attack.reset();
|
||||
HistoryElement::Clear();
|
||||
}
|
||||
|
||||
public:
|
||||
AttackUseHistory(const ExecutingAttack* attack) : _attack(attack) {}
|
||||
|
||||
HistoryElementKind GetKind() const noexcept override { return HistoryElementKind::AttackUse; }
|
||||
ArbUt::BorrowedPtr<const ExecutingAttack> GetAttack() { return _attack; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_ATTACKUSEHISTORY_HPP
|
||||
25
src/Battling/History/HistoryElements/HistoryElement.hpp
Normal file
25
src/Battling/History/HistoryElements/HistoryElement.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CREATURELIB_HISTORYELEMENT_HPP
|
||||
#define CREATURELIB_HISTORYELEMENT_HPP
|
||||
|
||||
#include <Arbutils/Memory/BorrowedPtr.hpp>
|
||||
#include "../HistoryElementKind.hpp"
|
||||
namespace CreatureLib::Battling {
|
||||
class HistoryElement {
|
||||
friend class HistoryHolder;
|
||||
HistoryElement* _previous;
|
||||
|
||||
protected:
|
||||
virtual void Clear() {
|
||||
if (_previous != nullptr) {
|
||||
_previous->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
virtual HistoryElementKind GetKind() const noexcept = 0;
|
||||
ArbUt::BorrowedPtr<const HistoryElement> GetPrevious() const noexcept { return _previous; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_HISTORYELEMENT_HPP
|
||||
Reference in New Issue
Block a user