本文整理汇总了C++中Inventory::getEquippedItems方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getEquippedItems方法的具体用法?C++ Inventory::getEquippedItems怎么用?C++ Inventory::getEquippedItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getEquippedItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static uint16_t getModifiedAttribute( const Inventory& inventory, const CCharacter* character, uint16_t basicAttributeValue, int16_t(*getItemAttribute)( Item* ), int16_t(*getSpellAttribute)( GeneralBuffSpell* ), uint16_t minValue = std::numeric_limits<uint16_t>::min(), uint16_t maxValue = std::numeric_limits<uint16_t>::max() )
{
int32_t attributeModifier = 0;
std::vector<InventoryItem*> equippedItems = inventory.getEquippedItems();
size_t numItems = equippedItems.size();
bool readTwoHandedWeapon = false;
for( size_t curItemNr=0; curItemNr<numItems; ++curItemNr )
{
Item* curItem = equippedItems[curItemNr]->getItem();
assert( curItem != NULL );
if ( curItem->isTwoHandedWeapon() == false || readTwoHandedWeapon == false )
{
attributeModifier += getItemAttribute( curItem );
}
// we do this because we only want to read the stats from two-handed weapons once and not two times as it would be since we equip two-handed weapons in both main-hand and off-hand slot.
if( curItem->isTwoHandedWeapon() )
{
readTwoHandedWeapon = true;
}
}
std::vector<std::pair<CSpellActionBase*, uint32_t> > activeSpells;
activeSpells = character ->getActiveSpells();
size_t numSpells = activeSpells.size();
for( size_t curSpellNr=0; curSpellNr<numSpells; ++curSpellNr )
{
GeneralBuffSpell *curSpell = dynamic_cast<GeneralBuffSpell*> ( activeSpells[ curSpellNr ].first );
// since more than Buffspells can be active, we want to check to see that we're getting a buff here...
if( curSpell != NULL )
{
attributeModifier += getSpellAttribute( curSpell );
}
}
if( static_cast<int32_t>( basicAttributeValue ) + attributeModifier < static_cast<int32_t>( minValue ) )
{
return minValue;
}
else if( static_cast<int32_t>( basicAttributeValue ) + attributeModifier > static_cast<int32_t>( maxValue ) )
{
return maxValue;
}
else
{
return basicAttributeValue + attributeModifier;
}
}