Rework several libraries to use new StringViewDictionary
This commit is contained in:
@@ -23,14 +23,14 @@ CreateCreature CreateCreature::WithAttack(const ArbUt::StringView& attackName, A
|
||||
THROW("You have already set the maximum amount of allowed moves.");
|
||||
}
|
||||
|
||||
auto attackData = _library->GetAttackLibrary()->Get(attackName.GetHash());
|
||||
auto attackData = _library->GetAttackLibrary()->Get(attackName);
|
||||
_attacks.Append(std::tuple(attackData, learnMethod));
|
||||
return *this;
|
||||
}
|
||||
|
||||
Creature* CreateCreature::Create() {
|
||||
auto rand = ArbUt::Random();
|
||||
auto species = this->_library->GetSpeciesLibrary()->Get(this->_species.GetHash());
|
||||
auto species = this->_library->GetSpeciesLibrary()->Get(this->_species);
|
||||
auto variant = species->GetVariant(this->_variant);
|
||||
Library::TalentIndex talent;
|
||||
if (this->_talent.IsEmpty()) {
|
||||
@@ -48,7 +48,7 @@ Creature* CreateCreature::Create() {
|
||||
}
|
||||
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem;
|
||||
if (!this->_heldItem.IsEmpty()) {
|
||||
auto val = _library->GetItemLibrary()->TryGet(this->_heldItem.GetHash());
|
||||
auto val = _library->GetItemLibrary()->TryGet(this->_heldItem);
|
||||
if (!val.has_value()) {
|
||||
THROW("Invalid held item '", this->_heldItem.c_str(), "'.");
|
||||
}
|
||||
|
||||
@@ -337,24 +337,24 @@ namespace CreatureLib::Battling {
|
||||
variant = _variant.GetRaw();
|
||||
return variant;
|
||||
}
|
||||
void Creature::SetHeldItem(const ArbUt::BasicStringView& itemName) {
|
||||
void Creature::SetHeldItem(const ArbUt::StringView& itemName) {
|
||||
if (itemName == ""_cnc) {
|
||||
_heldItem = {};
|
||||
_heldItemTriggerScript = {};
|
||||
} else {
|
||||
auto v = _library->GetItemLibrary()->TryGet(itemName.GetHash());
|
||||
auto v = _library->GetItemLibrary()->TryGet(itemName);
|
||||
if (!v.has_value()) {
|
||||
THROW("Item not found '", itemName.c_str(), "'.");
|
||||
}
|
||||
_heldItem = v.value();
|
||||
}
|
||||
}
|
||||
void Creature::SetHeldItem(u32 itemNameHash) {
|
||||
void Creature::SetHeldItemByHash(u32 itemNameHash) {
|
||||
if (itemNameHash == ArbUt::StringView::CalculateHash("")) {
|
||||
_heldItem = {};
|
||||
_heldItemTriggerScript = {};
|
||||
} else {
|
||||
auto v = _library->GetItemLibrary()->TryGet(itemNameHash);
|
||||
auto v = _library->GetItemLibrary()->TryGetByHash(itemNameHash);
|
||||
if (!v.has_value()) {
|
||||
THROW("Item not found.");
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ namespace CreatureLib::Battling {
|
||||
return _heldItem.HasValue() && _heldItem.GetValue()->GetName() == nameHash;
|
||||
}
|
||||
inline const ArbUt::OptionalBorrowedPtr<const Library::Item>& GetHeldItem() const noexcept { return _heldItem; }
|
||||
void SetHeldItem(const ArbUt::BasicStringView& itemName);
|
||||
void SetHeldItem(u32 itemNameHash);
|
||||
void SetHeldItem(const ArbUt::StringView& itemName);
|
||||
void SetHeldItemByHash(u32 itemNameHash);
|
||||
inline void SetHeldItem(const ArbUt::BorrowedPtr<const Library::Item>& item) noexcept { _heldItem = item; };
|
||||
bool ConsumeHeldItem();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user