Added display text event hook.
This commit is contained in:
@@ -52,6 +52,15 @@ namespace CreatureLib::Battling {
|
||||
Creature* GetCreature() const { return _creature; }
|
||||
};
|
||||
|
||||
class DisplayTextEvent : public EventData {
|
||||
const std::string _text;
|
||||
|
||||
public:
|
||||
DisplayTextEvent(const std::string& text) : _text(text) {}
|
||||
EventDataKind GetKind() const override { return EventDataKind ::DisplayText; }
|
||||
const std::string& GetText() const { return _text; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EVENTDATA_HPP
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint)
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint, DisplayText)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace CreatureLib::Battling {
|
||||
public:
|
||||
void RegisterListener(EVENT_HOOK_FUNC(func)) { _listeners.push_back(func); }
|
||||
|
||||
void TriggerEvent(EventData* eventData) {
|
||||
void TriggerEvent(EventData* eventData) const {
|
||||
for (auto listener : _listeners) {
|
||||
listener(eventData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user