Updates to upgrades

This commit is contained in:
wincent
2024-06-06 09:37:24 +02:00
parent 364bcf822a
commit ac1b00fdaa
7 changed files with 209 additions and 3 deletions

View File

@@ -1617,3 +1617,31 @@ bool InventoryComponent::SetSkill(BehaviorSlot slot, uint32_t skillId) {
m_Skills.insert_or_assign(slot, skillId);
return true;
}
void InventoryComponent::UnsetSkill(BehaviorSlot slot) {
const auto index = m_Skills.find(slot);
if (index == m_Skills.end()) return;
const auto old = index->second;
GameMessages::SendRemoveSkill(m_Parent, old);
m_Skills.erase(slot);
}
void InventoryComponent::ResetSkill(BehaviorSlot slot) {
const auto index = m_Skills.find(slot);
if (index == m_Skills.end()) return;
const auto old = index->second;
GameMessages::SendRemoveSkill(m_Parent, old);
m_Skills.erase(slot);
// Loop through all equipped items and find the first item that can be equipped in the slot
for (const auto& pair : m_Equipped) {
const auto item = pair.second;
const auto info = Inventory::FindItemComponent(item.lot);
const auto behaviorSlot = FindBehaviorSlot(static_cast<eItemType>(info.itemType));
if (behaviorSlot == slot) {
SetSkill(slot, FindSkill(item.lot));
return;
}
}
}

View File

@@ -372,6 +372,8 @@ public:
bool SetSkill(int slot, uint32_t skillId);
bool SetSkill(BehaviorSlot slot, uint32_t skillId);
void UnsetSkill(BehaviorSlot slot);
void ResetSkill(BehaviorSlot slot);
~InventoryComponent() override;