Support for (un)suppressing weather, adds hook to block weather changes.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
#include "Battle.hpp"
|
||||
void PkmnLib::Battling::Battle::SetWeather(const ArbUt::StringView& name) {
|
||||
#include "../PkmnScriptHook.hpp"
|
||||
bool PkmnLib::Battling::Battle::SetWeather(const ArbUt::StringView& name) {
|
||||
bool blockWeather = false;
|
||||
PKMN_HOOK(BlockWeather, this, this, &blockWeather);
|
||||
if (blockWeather) {
|
||||
return false;
|
||||
}
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->OnRemove();
|
||||
}
|
||||
_weatherScript = std::unique_ptr<CreatureLib::Battling::BattleScript>(
|
||||
_library->LoadScript(this, static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name));
|
||||
_eventHook.Trigger<WeatherChangeEvent>(name);
|
||||
return true;
|
||||
}
|
||||
void PkmnLib::Battling::Battle::ClearWeather() {
|
||||
if (_weatherScript == nullptr)
|
||||
|
||||
@@ -22,8 +22,19 @@ namespace PkmnLib::Battling {
|
||||
|
||||
virtual ~Battle() = default;
|
||||
|
||||
void SetWeather(const ArbUt::StringView& name);
|
||||
bool SetWeather(const ArbUt::StringView& name);
|
||||
void ClearWeather();
|
||||
void SuppressWeather() {
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->Suppress();
|
||||
}
|
||||
}
|
||||
void UnsuppressWeather() {
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->Unsuppress();
|
||||
}
|
||||
}
|
||||
|
||||
const ArbUt::StringView& GetWeatherName() noexcept {
|
||||
if (_weatherScript == nullptr)
|
||||
return ArbUt::StringView::EmptyString();
|
||||
|
||||
Reference in New Issue
Block a user