Cleans up HistoryHolder to be a lot less complicated (although possibly a bit slower), adds DamageHistory.
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -112,7 +112,7 @@ namespace CreatureLib::Battling {
|
||||
const EventHook& GetEventHook() const noexcept { return _eventHook; }
|
||||
|
||||
template <HistoryElementType T, class... parameters> void RegisterHistoryElement(parameters... args) {
|
||||
try_creature(this->_historyHolder.Register<T>(args...);
|
||||
try_creature(this->_historyHolder.Register<T>(this->GetCurrentTurn(), args...);
|
||||
, "Exception occurred during history element registration.");
|
||||
}
|
||||
const HistoryHolder& GetHistory() const noexcept { return _historyHolder; }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Creature.hpp"
|
||||
#include <utility>
|
||||
#include "../EventHooks/EventDataClasses.hpp"
|
||||
#include "../History/HistoryElements/DamageHistory.hpp"
|
||||
#include "../Models/Battle.hpp"
|
||||
#include "../ScriptHandling/ScriptMacros.hpp"
|
||||
|
||||
@@ -176,6 +177,7 @@ namespace CreatureLib::Battling {
|
||||
auto battle = this->GetBattle();
|
||||
if (battle.HasValue()) {
|
||||
battle.GetValue()->TriggerEventListener<DamageEvent>(this, source, _currentHealth, newHealth);
|
||||
battle.GetValue()->RegisterHistoryElement<DamageHistory>(this, damage, source);
|
||||
}
|
||||
_currentHealth = newHealth;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user