Make HeldItem OptionalBorrowedPtr.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ namespace CreatureLib::Battling {
|
||||
uint32_t _uniqueIdentifier;
|
||||
Library::Gender _gender;
|
||||
uint8_t _coloring;
|
||||
ArbUt::BorrowedPtr<const Library::Item> _heldItem;
|
||||
ArbUt::OptionalBorrowedPtr<const Library::Item> _heldItem;
|
||||
uint32_t _currentHealth = -1;
|
||||
|
||||
Library::ClampedStatisticSet<int8_t, -6, 6> _statBoost;
|
||||
@@ -67,7 +67,7 @@ namespace CreatureLib::Battling {
|
||||
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
||||
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
||||
const ArbUt::BorrowedPtr<const Library::Item> heldItem, const std::string& nickname,
|
||||
const ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, const std::string& nickname,
|
||||
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
||||
bool allowedExperienceGain = true);
|
||||
|
||||
@@ -92,12 +92,12 @@ namespace CreatureLib::Battling {
|
||||
inline Library::Gender GetGender() const noexcept { return _gender; }
|
||||
inline uint8_t GetColoring() const noexcept { return _coloring; }
|
||||
inline bool HasHeldItem(const ArbUt::BasicStringView& name) const noexcept {
|
||||
return _heldItem != nullptr && _heldItem->GetName() == name;
|
||||
return _heldItem.HasValue() && _heldItem.GetValue()->GetName() == name;
|
||||
}
|
||||
inline bool HasHeldItem(uint32_t nameHash) const noexcept {
|
||||
return _heldItem != nullptr && _heldItem->GetName() == nameHash;
|
||||
return _heldItem.HasValue() && _heldItem.GetValue()->GetName() == nameHash;
|
||||
}
|
||||
inline const ArbUt::BorrowedPtr<const Library::Item>& GetHeldItem() const noexcept { return _heldItem; }
|
||||
inline const ArbUt::OptionalBorrowedPtr<const Library::Item>& GetHeldItem() const noexcept { return _heldItem; }
|
||||
void SetHeldItem(const ArbUt::BasicStringView& itemName);
|
||||
void SetHeldItem(uint32_t itemNameHash);
|
||||
inline void SetHeldItem(const ArbUt::BorrowedPtr<const Library::Item>& item) noexcept { _heldItem = item; };
|
||||
|
||||
Reference in New Issue
Block a user