diff --git a/src/Battling/Battle/Battle.hpp b/src/Battling/Battle/Battle.hpp index 44ea342..39d48e7 100644 --- a/src/Battling/Battle/Battle.hpp +++ b/src/Battling/Battle/Battle.hpp @@ -2,6 +2,7 @@ #define PKMNLIB_BATTLE_HPP #include +#include "../EventHooks/WeatherChangeEvent.hpp" #include "../Library/BattleLibrary.hpp" #include "../PkmnScriptCategory.hpp" @@ -21,11 +22,13 @@ namespace PkmnLib::Battling { delete _weatherScript; } _weatherScript = _library->LoadScript(static_cast(PkmnScriptCategory::Weather), name); + _eventHook.TriggerEvent(new WeatherChangeEvent(name)); } void ClearWeather() { _weatherScript->OnRemove(); delete _weatherScript; _weatherScript = nullptr; + _eventHook.TriggerEvent(new WeatherChangeEvent(""_cnc)); } const Arbutils::CaseInsensitiveConstString& GetWeatherName() noexcept { return _weatherScript->GetName(); } diff --git a/src/Battling/EventHooks/PkmnEventKind.hpp b/src/Battling/EventHooks/PkmnEventKind.hpp new file mode 100644 index 0000000..210ccef --- /dev/null +++ b/src/Battling/EventHooks/PkmnEventKind.hpp @@ -0,0 +1,9 @@ +#ifndef PKMNLIB_PKMNEVENTKIND_HPP +#define PKMNLIB_PKMNEVENTKIND_HPP +#include +#include + +ENUM_WITH_START_VALUE(PkmnEventDataKind, uint8_t, ((uint8_t)CreatureLib::Battling::EventDataKindHelper::Highest()) + 1, + WeatherChange) + +#endif // PKMNLIB_PKMNEVENTKIND_HPP diff --git a/src/Battling/EventHooks/WeatherChangeEvent.hpp b/src/Battling/EventHooks/WeatherChangeEvent.hpp new file mode 100644 index 0000000..bf79ad1 --- /dev/null +++ b/src/Battling/EventHooks/WeatherChangeEvent.hpp @@ -0,0 +1,20 @@ +#ifndef PKMNLIB_WEATHERCHANGEEVENT_HPP +#define PKMNLIB_WEATHERCHANGEEVENT_HPP +#include +#include +#include "PkmnEventKind.hpp" + +namespace PkmnLib::Battling { + class WeatherChangeEvent : public CreatureLib::Battling::EventData { + Arbutils::CaseInsensitiveConstString _weatherName; + + public: + explicit WeatherChangeEvent(const Arbutils::CaseInsensitiveConstString& name) : _weatherName(name) {} + + [[nodiscard]] CreatureLib::Battling::EventDataKind GetKind() const noexcept override { + return static_cast(PkmnEventDataKind::WeatherChange); + } + }; +} + +#endif // PKMNLIB_WEATHERCHANGEEVENT_HPP