Update to latest CreatureLib
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:
@@ -6,18 +6,18 @@ bool PkmnLib::Battling::Battle::SetWeather(const ArbUt::StringView& name) {
|
||||
if (blockWeather) {
|
||||
return false;
|
||||
}
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->OnRemove();
|
||||
if (_weatherScript.HasValue()) {
|
||||
_weatherScript.GetValue()->OnRemove();
|
||||
}
|
||||
_weatherScript = std::unique_ptr<CreatureLib::Battling::BattleScript>(
|
||||
_library->LoadScript(this, static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name));
|
||||
_weatherScript =
|
||||
_library->LoadScript(this, static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name).TakeOwnership();
|
||||
_eventHook.Trigger<WeatherChangeEvent>(name);
|
||||
return true;
|
||||
}
|
||||
void PkmnLib::Battling::Battle::ClearWeather() {
|
||||
if (_weatherScript == nullptr)
|
||||
if (!_weatherScript.HasValue())
|
||||
return;
|
||||
_weatherScript->OnRemove();
|
||||
_weatherScript.GetValue()->OnRemove();
|
||||
_weatherScript = nullptr;
|
||||
_eventHook.Trigger<WeatherChangeEvent>(""_cnc);
|
||||
}
|
||||
@@ -65,8 +65,8 @@ PkmnLib::Battling::Battle* PkmnLib::Battling::Battle::Clone() const {
|
||||
battle->_battleResult = _battleResult;
|
||||
battle->_currentTurn = _currentTurn;
|
||||
_volatile.Clone(battle, battle->_volatile);
|
||||
if (_weatherScript != nullptr) {
|
||||
battle->_weatherScript = std::unique_ptr<CreatureLib::Battling::BattleScript>(_weatherScript->Clone(battle));
|
||||
if (_weatherScript.HasValue()) {
|
||||
battle->_weatherScript = _weatherScript.GetValue()->Clone(battle);
|
||||
}
|
||||
|
||||
return battle;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace PkmnLib::Battling {
|
||||
class Battle : public CreatureLib::Battling::Battle {
|
||||
private:
|
||||
std::unique_ptr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
|
||||
|
||||
public:
|
||||
Battle(const BattleLibrary* non_null library,
|
||||
@@ -26,20 +26,21 @@ namespace PkmnLib::Battling {
|
||||
bool SetWeather(const ArbUt::StringView& name);
|
||||
void ClearWeather();
|
||||
void SuppressWeather() {
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->Suppress();
|
||||
if (_weatherScript.HasValue()) {
|
||||
_weatherScript.GetValue()->Suppress();
|
||||
}
|
||||
}
|
||||
void UnsuppressWeather() {
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->Unsuppress();
|
||||
if (_weatherScript.HasValue()) {
|
||||
_weatherScript.GetValue()->Unsuppress();
|
||||
}
|
||||
}
|
||||
|
||||
const ArbUt::StringView& GetWeatherName() noexcept {
|
||||
if (_weatherScript == nullptr)
|
||||
if (!_weatherScript.HasValue()) {
|
||||
return ArbUt::StringView::EmptyString();
|
||||
return _weatherScript->GetName();
|
||||
}
|
||||
return _weatherScript.GetValue()->GetName();
|
||||
}
|
||||
|
||||
size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; }
|
||||
|
||||
Reference in New Issue
Block a user