本文整理汇总了C++中ContainerStoreIterator::getContainerStore方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerStoreIterator::getContainerStore方法的具体用法?C++ ContainerStoreIterator::getContainerStore怎么用?C++ ContainerStoreIterator::getContainerStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerStoreIterator
的用法示例。
在下文中一共展示了ContainerStoreIterator::getContainerStore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& iterator, const Ptr& actor)
{
if (iterator == end())
throw std::runtime_error ("can't equip end() iterator, use unequip function instead");
if (slot<0 || slot>=static_cast<int> (mSlots.size()))
throw std::runtime_error ("slot number out of range");
if (iterator.getContainerStore()!=this)
throw std::runtime_error ("attempt to equip an item that is not in the inventory");
std::pair<std::vector<int>, bool> slots_;
slots_ = iterator->getClass().getEquipmentSlots (*iterator);
if (std::find (slots_.first.begin(), slots_.first.end(), slot)==slots_.first.end())
throw std::runtime_error ("invalid slot");
if (mSlots[slot] != end())
unequipSlot(slot, actor);
// unstack item pointed to by iterator if required
if (iterator!=end() && !slots_.second && iterator->getRefData().getCount() > 1) // if slots.second is true, item can stay stacked when equipped
{
unstack(*iterator, actor);
}
mSlots[slot] = iterator;
flagAsModified();
fireEquipmentChangedEvent(actor);
updateMagicEffects(actor);
}
示例2: runtime_error
void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& iterator)
{
if (slot<0 || slot>=static_cast<int> (mSlots.size()))
throw std::runtime_error ("slot number out of range");
if (iterator.getContainerStore()!=this)
throw std::runtime_error ("attempt to equip an item that is not in the inventory");
if (iterator!=end())
{
std::pair<std::vector<int>, bool> slots = Class::get (*iterator).getEquipmentSlots (*iterator);
if (std::find (slots.first.begin(), slots.first.end(), slot)==slots.first.end())
throw std::runtime_error ("invalid slot");
}
/// \todo restack item previously in this slot (if required)
/// \todo unstack item pointed to by iterator if required)
mSlots[slot] = iterator;
}