void CharacterCore::loadEquipmentItems() { clearEquippedItems(); Weapon* eqWeapon = nullptr; Item* eqBack = nullptr; Item* eqBody = nullptr; Item* eqHead = nullptr; Item* eqNeck = nullptr; Item* eqRing1 = nullptr; Item* eqRing2 = nullptr; if (!m_data.equippedWeapon.empty() && g_resourceManager->getItemBean(m_data.equippedWeapon) != nullptr) { eqWeapon = new Weapon(*g_resourceManager->getItemBean(m_data.equippedWeapon)); // add equipped spells and their modifiers for (int slot = 0; slot < m_data.equippedWeaponSlots.size(); slot++) { eqWeapon->addSpell(slot, m_data.equippedWeaponSlots[slot].first, false); for (auto& it : m_data.equippedWeaponSlots[slot].second) { eqWeapon->addModifier(slot, it, false); } } } if (!m_data.equippedBack.empty() && g_resourceManager->getItemBean(m_data.equippedBack) != nullptr) { eqBack = new Item(*g_resourceManager->getItemBean(m_data.equippedBack)); } if (!m_data.equippedBody.empty() && g_resourceManager->getItemBean(m_data.equippedBody) != nullptr) { eqBody = new Item(*g_resourceManager->getItemBean(m_data.equippedBody)); } if (!m_data.equippedHead.empty() && g_resourceManager->getItemBean(m_data.equippedHead) != nullptr) { eqHead = new Item(*g_resourceManager->getItemBean(m_data.equippedHead)); } if (!m_data.equippedNeck.empty() && g_resourceManager->getItemBean(m_data.equippedNeck) != nullptr) { eqNeck = new Item(*g_resourceManager->getItemBean(m_data.equippedNeck)); } if (!m_data.equippedRing1.empty() && g_resourceManager->getItemBean(m_data.equippedRing1) != nullptr) { eqRing1 = new Item(*g_resourceManager->getItemBean(m_data.equippedRing1)); } if (!m_data.equippedRing2.empty() && g_resourceManager->getItemBean(m_data.equippedRing2) != nullptr) { eqRing2 = new Item(*g_resourceManager->getItemBean(m_data.equippedRing2)); } m_equippedItems.insert({ ItemType::Equipment_weapon, eqWeapon }); m_equippedItems.insert({ ItemType::Equipment_back, eqBack }); m_equippedItems.insert({ ItemType::Equipment_body, eqBody }); m_equippedItems.insert({ ItemType::Equipment_head, eqHead }); m_equippedItems.insert({ ItemType::Equipment_neck, eqNeck }); m_equippedItems.insert({ ItemType::Equipment_ring_1, eqRing1 }); m_equippedItems.insert({ ItemType::Equipment_ring_2, eqRing2 }); }
void CharacterCore::reloadWeaponSlots() { Weapon* wep = dynamic_cast<Weapon*>(m_equippedItems.at(ItemType::Equipment_weapon)); if (wep == nullptr) return; wep->reload(); for (int slot = 0; slot < m_data.equippedWeaponSlots.size(); slot++) { wep->addSpell(slot, m_data.equippedWeaponSlots[slot].first, false); for (int i = 0; i < m_data.equippedWeaponSlots[slot].second.size(); ++i) { wep->addModifier(slot, i, m_data.equippedWeaponSlots[slot].second[i], false); } } }