void Wearer::assignItemsToSlots() { for ( ActorPtr a : _equippedItems->toVector() ) { PickablePtr pickable = a ? a->getFeature<Pickable>() : nullptr; if ( pickable && hasSlot( pickable->getItemSlot() )) { _itemSlots[ pickable->getItemSlot() ] = std::make_pair(a, false); } } }
bool Wearer::equip(ActorPtr item) { if ( !item ) return false; PickablePtr pickable = item->getFeature<Pickable>(); if ( !pickable ) return false; ItemSlotType slot = pickable->getItemSlot(); if ( hasSlot(slot) && !isEquipped(slot) ) { _equippedItems->push_back(item); _itemSlots[slot] = std::make_pair(item, false); return true; } return false; }