diff --git a/CInterface/Battling/Creature.cpp b/CInterface/Battling/Creature.cpp index 3423174..4005e9a 100644 --- a/CInterface/Battling/Creature.cpp +++ b/CInterface/Battling/Creature.cpp @@ -64,8 +64,8 @@ export_func const char* CreatureLib_Creature_GetNickname(Creature* p) { } export_func void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); } export_func bool CreatureLib_Creature_HasType(Creature* p, u8 type) { return p->HasType(type); } -export_func size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); } -export_func const u8* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); } +export_func size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().Count(); } +export_func const u8* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().RawData(); } SIMPLE_GET_FUNC(Creature, GetMaxHealth, u32); export_func u8 CreatureLib_Creature_ChangeLevelBy(Creature* p, i8 level) { Try(p->ChangeLevelBy(level);) } export_func u8 CreatureLib_Creature_Damage(Creature* p, u32 damage, DamageSource source) { diff --git a/CInterface/Library/TypeLibrary.cpp b/CInterface/Library/TypeLibrary.cpp index 70c127d..dec3390 100644 --- a/CInterface/Library/TypeLibrary.cpp +++ b/CInterface/Library/TypeLibrary.cpp @@ -26,7 +26,7 @@ export_func u8 CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLi export_func u8 CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive[], size_t defensiveCount) { - Try(out = p->GetEffectiveness(attacking, std::vector(defensive, defensive + defensiveCount));) + Try(out = p->GetEffectiveness(attacking, ArbUt::List(defensive, defensive + defensiveCount));) } export_func u8 CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, u8 type) { Try(out = p->GetTypeName(type).c_str();) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index a2cd5a0..5e97902 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -34,7 +34,7 @@ namespace CreatureLib::Battling { .TakeOwnership(); } for (auto t : _variant->GetTypes()) { - _types.push_back(t); + _types.Append(t); } } @@ -75,9 +75,9 @@ namespace CreatureLib::Battling { _variant = variant; // Set the types to the new variant. - _types.clear(); + _types.Clear(); for (auto t : variant->GetTypes()) { - _types.push_back(t); + _types.Append(t); } _weight = variant->GetWeight(); @@ -136,9 +136,9 @@ namespace CreatureLib::Battling { ResetActiveScripts(); _weight = _variant->GetWeight(); _height = _variant->GetHeight(); - _types.clear(); + _types.Clear(); for (auto t : _variant->GetTypes()) { - _types.push_back(t); + _types.Append(t); } } @@ -273,17 +273,11 @@ namespace CreatureLib::Battling { _overridenTalent = _library->GetStaticLib()->GetTalentLibrary()->Get(talent); } - const std::vector& Creature::GetTypes() const noexcept { return _types; } - - bool Creature::HasType(u8 type) const noexcept { - return std::find(_types.begin(), _types.end(), type) != _types.end(); - } - void Creature::SetType(u8 index, u8 type) noexcept { - if (_types.size() > index) { + if (_types.Count() > index) { _types[index] = type; } else { - _types.push_back(type); + _types.Append(type); } } @@ -474,7 +468,7 @@ namespace CreatureLib::Battling { c->_status = _status.GetValue()->Clone(c); } _volatile.Clone(c, c->_volatile); - c->_types = std::vector(_types); + c->_types = ArbUt::List(_types); c->RecalculateFlatStats(); return c; diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index a94d04c..5b942ad 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -64,7 +64,7 @@ namespace CreatureLib::Battling { ArbUt::OptionalUniquePtr _status = nullptr; ScriptSet _volatile = {}; - std::vector _types = {}; + ArbUt::List _types = {}; ArbUt::OptionalBorrowedPtr _heldItem; ArbUt::OptionalUniquePtr _heldItemTriggerScript = nullptr; @@ -153,8 +153,8 @@ namespace CreatureLib::Battling { /// Are we allowed to use this creature in a battle? [[nodiscard]] virtual bool IsUsable() const noexcept; [[nodiscard]] bool IsFainted() const noexcept; - [[nodiscard]] const std::vector& GetTypes() const noexcept; - [[nodiscard]] bool HasType(u8 type) const noexcept; + [[nodiscard]] inline const ArbUt::List& GetTypes() const noexcept { return _types; } + [[nodiscard]] inline bool HasType(u8 type) const noexcept { return _types.Contains(type); } void SetType(u8 index, u8 type) noexcept; u32 GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); } diff --git a/src/Library/TypeLibrary.hpp b/src/Library/TypeLibrary.hpp index 76bbf31..26cc9f9 100644 --- a/src/Library/TypeLibrary.hpp +++ b/src/Library/TypeLibrary.hpp @@ -27,7 +27,7 @@ namespace CreatureLib::Library { (u32)defensive); } } - [[nodiscard]] inline float GetEffectiveness(u8 attacking, const std::vector& defensive) const { + [[nodiscard]] inline float GetEffectiveness(u8 attacking, const ArbUt::List& defensive) const { return std::accumulate(defensive.begin(), defensive.end(), (float)1, [this, attacking](float init, u8 defense) { return init * GetSingleEffectiveness(attacking, defense);