Change Creature::Nickname to be an optional.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
152ac7e407
commit
ce30077a5d
|
@ -55,7 +55,13 @@ SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
|
||||||
OPTIONAL_GET_FUNC(Creature, GetBattle, Battle*);
|
OPTIONAL_GET_FUNC(Creature, GetBattle, Battle*);
|
||||||
OPTIONAL_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
OPTIONAL_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
||||||
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
||||||
export const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().data(); }
|
export const char* CreatureLib_Creature_GetNickname(Creature* p) {
|
||||||
|
auto s = p->GetNickname();
|
||||||
|
if (s.has_value()) {
|
||||||
|
return p->GetNickname().value().data();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
export void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); }
|
export void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); }
|
||||||
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
||||||
export size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); }
|
export size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); }
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace CreatureLib::Battling {
|
||||||
ArbUt::StringView _species;
|
ArbUt::StringView _species;
|
||||||
ArbUt::StringView _variant = "default"_cnc;
|
ArbUt::StringView _variant = "default"_cnc;
|
||||||
uint8_t _level;
|
uint8_t _level;
|
||||||
std::string _nickname = "";
|
std::optional<std::string> _nickname = "";
|
||||||
|
|
||||||
ArbUt::StringView _talent = ""_cnc;
|
ArbUt::StringView _talent = ""_cnc;
|
||||||
Library::Gender _gender = static_cast<Library::Gender>(-1);
|
Library::Gender _gender = static_cast<Library::Gender>(-1);
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace CreatureLib::Battling {
|
||||||
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
||||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
||||||
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
||||||
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, std::string nickname,
|
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, std::optional<std::string> nickname,
|
||||||
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
||||||
bool allowedExperienceGain)
|
bool allowedExperienceGain)
|
||||||
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
|
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace CreatureLib::Battling {
|
||||||
std::unordered_set<ArbUt::BorrowedPtr<Creature>> SeenOpponents;
|
std::unordered_set<ArbUt::BorrowedPtr<Creature>> SeenOpponents;
|
||||||
} _battleData = {};
|
} _battleData = {};
|
||||||
|
|
||||||
std::string _nickname = {};
|
std::optional<std::string> _nickname = {};
|
||||||
CreatureLib::Library::TalentIndex _talentIndex = {};
|
CreatureLib::Library::TalentIndex _talentIndex = {};
|
||||||
std::unique_ptr<BattleScript> _activeTalent = {};
|
std::unique_ptr<BattleScript> _activeTalent = {};
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace CreatureLib::Battling {
|
||||||
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
||||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
||||||
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
||||||
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, std::string nickname,
|
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, std::optional<std::string> nickname,
|
||||||
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
||||||
bool allowedExperienceGain = true);
|
bool allowedExperienceGain = true);
|
||||||
|
|
||||||
|
@ -117,7 +117,12 @@ namespace CreatureLib::Battling {
|
||||||
inline const CreatureIndex& GetBattleIndex() const noexcept { return _battleData.Index; }
|
inline const CreatureIndex& GetBattleIndex() const noexcept { return _battleData.Index; }
|
||||||
inline bool IsOnBattleField() const { return _battleData.OnBattleField; }
|
inline bool IsOnBattleField() const { return _battleData.OnBattleField; }
|
||||||
|
|
||||||
inline std::string_view GetNickname() const noexcept { return _nickname; }
|
inline std::optional<std::string_view> GetNickname() const noexcept {
|
||||||
|
if (_nickname.has_value()) {
|
||||||
|
return _nickname.value();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
inline void SetNickname(std::string nickname) noexcept { _nickname = nickname; }
|
inline void SetNickname(std::string nickname) noexcept { _nickname = nickname; }
|
||||||
const CreatureLib::Library::TalentIndex& GetRealTalent() const noexcept { return _talentIndex; }
|
const CreatureLib::Library::TalentIndex& GetRealTalent() const noexcept { return _talentIndex; }
|
||||||
const ArbUt::StringView& GetActiveTalent() const;
|
const ArbUt::StringView& GetActiveTalent() const;
|
||||||
|
|
Loading…
Reference in New Issue