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; }
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace PkmnLib::Battling {
|
||||
auto rate = pokemon->GetSpecies()->GetCaptureRate();
|
||||
|
||||
u8 bonusBall = 1;
|
||||
auto* itemScript =
|
||||
dynamic_cast<PkmnItemUseScript*>(pokemon->GetLibrary()->GetScriptResolver()->LoadItemScript(catchItem));
|
||||
auto* itemScript = dynamic_cast<PkmnItemUseScript*>(
|
||||
pokemon->GetLibrary()->GetScriptResolver()->LoadItemScript(catchItem).GetValue());
|
||||
itemScript->ModifyPokeballCatchBonus(pokemon, &bonusBall);
|
||||
|
||||
u8 bonusStatus = 1;
|
||||
|
||||
@@ -53,13 +53,13 @@ CreatureLib::Battling::Creature* PkmnLib::Battling::Pokemon::Clone() const {
|
||||
c->_battleData.Side = _battleData.Side;
|
||||
c->_battleData.OnBattleField = _battleData.OnBattleField;
|
||||
c->_battleData.Index = _battleData.Index;
|
||||
if (_activeTalent != nullptr) {
|
||||
c->_activeTalent = std::unique_ptr<PkmnScript::BattleScript>(_activeTalent->Clone(c));
|
||||
if (_activeTalent.HasValue()) {
|
||||
c->_activeTalent = _activeTalent.GetValue()->Clone(c);
|
||||
}
|
||||
c->_hasOverridenTalent = _hasOverridenTalent;
|
||||
c->_overridenTalent = _overridenTalent;
|
||||
if (_status != nullptr) {
|
||||
c->_status = std::unique_ptr<PkmnScript::BattleScript>(_status->Clone(c));
|
||||
if (_status.HasValue()) {
|
||||
c->_status = _status.GetValue()->Clone(c);
|
||||
}
|
||||
_volatile.Clone(c, c->_volatile);
|
||||
c->_types = std::vector<u8>(_types);
|
||||
|
||||
@@ -165,9 +165,9 @@ void AngelScriptResolver::MessageCallback(const asSMessageInfo* msg, void*) {
|
||||
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
|
||||
}
|
||||
|
||||
CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) {
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript>
|
||||
AngelScriptResolver::LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner, ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) {
|
||||
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> innerDb;
|
||||
auto v = _typeDatabase.TryGet(category);
|
||||
if (!v.has_value()) {
|
||||
@@ -193,10 +193,11 @@ CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(const ArbUt
|
||||
return new AngelScriptScript(owner, ownerType, this, t.value(), obj, _contextPool);
|
||||
}
|
||||
|
||||
PkmnLib::Battling::PkmnItemUseScript* AngelScriptResolver::LoadItemScript(const CreatureLib::Library::Item* item) {
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::ItemUseScript>
|
||||
AngelScriptResolver::LoadItemScript(const CreatureLib::Library::Item* item) {
|
||||
auto v = this->_itemUseScripts.TryGet(item);
|
||||
if (v.has_value()) {
|
||||
return v.value();
|
||||
return {v.value()};
|
||||
}
|
||||
if (!item->GetEffect().HasValue()) {
|
||||
return nullptr;
|
||||
|
||||
@@ -66,10 +66,11 @@ public:
|
||||
|
||||
void DefineWord(const std::string& word) { _builder.DefineWord(word.c_str()); }
|
||||
|
||||
CreatureLib::Battling::BattleScript* LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) override;
|
||||
PkmnLib::Battling::PkmnItemUseScript* LoadItemScript(const CreatureLib::Library::Item* item) override;
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript>
|
||||
LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner, ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) override;
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::ItemUseScript>
|
||||
LoadItemScript(const CreatureLib::Library::Item* item) override;
|
||||
|
||||
ArbUt::OptionalBorrowedPtr<const PkmnLib::Battling::EvolutionScript>
|
||||
LoadEvolutionScript(const ArbUt::StringView& view) override;
|
||||
|
||||
@@ -11,7 +11,7 @@ class WebAssemblyFunctionCall {
|
||||
public:
|
||||
WebAssemblyFunctionCall(const ArbUt::BorrowedPtr<wasm_func_t>& func) : _func(func) {}
|
||||
|
||||
NO_COPY_OR_MOVE(WebAssemblyFunctionCall)
|
||||
NO_COPY_OR_MOVE(WebAssemblyFunctionCall);
|
||||
|
||||
void Call() {
|
||||
wasm_val_vec_t args = {argsCount, _arguments.Data};
|
||||
|
||||
@@ -132,7 +132,7 @@ void WebAssemblyScriptResolver::Finalize() {
|
||||
}
|
||||
}
|
||||
|
||||
CreatureLib::Battling::BattleScript*
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript>
|
||||
WebAssemblyScriptResolver::LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner, ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) {
|
||||
auto loadScriptOpt = GetFunction<2, 1>("load_script"_cnc);
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
[[nodiscard]] inline wasm_memory_t* GetMemory() const noexcept { return _memory; }
|
||||
|
||||
CreatureLib::Battling::BattleScript* LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript> LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) nullable override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user