本文整理汇总了C++中CItemContainer::ContentCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemContainer::ContentCount方法的具体用法?C++ CItemContainer::ContentCount怎么用?C++ CItemContainer::ContentCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemContainer
的用法示例。
在下文中一共展示了CItemContainer::ContentCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateItem
void CItemSpawn::GenerateItem(CResourceDef *pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateItem");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
CItemContainer *pCont = dynamic_cast<CItemContainer *>(GetParent());
BYTE iCount = pCont ? static_cast<unsigned char>(pCont->ContentCount(rid)) : GetCount();
if ( iCount >= GetAmount() )
return;
CItem *pItem = CreateTemplate(id);
if ( pItem == NULL )
return;
WORD iAmountPile = static_cast<WORD>(minimum(USHRT_MAX,m_itSpawnItem.m_pile));
if ( iAmountPile > 1 )
{
CItemBase *pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType() )
pItem->SetAmount(Calc_GetRandVal(iAmountPile) + 1);
}
pItem->SetAttr(m_Attr & (ATTR_OWNED | ATTR_MOVE_ALWAYS));
pItem->SetDecayTime(g_Cfg.m_iDecay_Item); // it will decay eventually to be replaced later
pItem->MoveNearObj(this, m_itSpawnItem.m_DistMax);
AddObj(pItem->GetUID());
}
示例2: GenerateItem
void CItemSpawn::GenerateItem(CResourceDef * pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateItem");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
int iDistMax = m_itSpawnItem.m_DistMax;
int iAmountPile = m_itSpawnItem.m_pile;
int iCount = 0;
CItemContainer * pCont = dynamic_cast <CItemContainer *>( GetParent());
if ( pCont != NULL )
iCount = pCont->ContentCount( rid );
else
iCount = GetCount();
if ( iCount >= GetAmount())
return;
CItem * pItem = CreateTemplate( id );
if ( pItem == NULL )
return;
pItem->SetAttr( m_Attr & ( ATTR_OWNED | ATTR_MOVE_ALWAYS ));
if ( iAmountPile > 1 )
{
CItemBase * pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType())
{
if ( iAmountPile == 0 || iAmountPile > GetAmount())
iAmountPile = GetAmount();
pItem->SetAmount( Calc_GetRandVal(iAmountPile) + 1 );
}
}
pItem->SetDecayTime( g_Cfg.m_iDecay_Item ); // It will decay eventually to be replaced later.
pItem->MoveNearObj( this, iDistMax );
AddObj(pItem->GetUID());
pItem->m_uidSpawnItem = GetUID();
}
示例3: Spawn_GenerateItem
void CItem::Spawn_GenerateItem( CResourceDef * pDef )
{
// Count how many items are here already.
// This could be in a container.
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = (ITEMID_TYPE) rid.GetResIndex();
int iDistMax = m_itSpawnItem.m_DistMax;
int iAmountPile = m_itSpawnItem.m_pile;
int iCount = 0;
CItemContainer * pCont = dynamic_cast <CItemContainer *>( GetParent());
if ( pCont != NULL )
{
iCount = pCont->ContentCount( rid );
}
else
{
// If is equipped this will produce the item where you are standing.
CPointMap pt = GetTopLevelObj()->GetTopPoint();
CWorldSearch AreaItems( pt, iDistMax );
while (true)
{
CItem * pItem = AreaItems.GetItem();
if ( pItem == NULL )
break;
if ( pItem->IsType(IT_SPAWN_ITEM))
continue;
if ( pItem->IsAttr( ATTR_INVIS ))
continue;
if ( pItem->GetID() != id )
continue;
// if ( pItem->m_uidLink != GetUID()) continue;
iCount += pItem->GetAmount();
}
}
if ( iCount >= GetAmount())
return;
CItem * pItem = CreateTemplate( id );
if ( pItem == NULL )
return;
pItem->SetAttr( m_Attr & ( ATTR_OWNED | ATTR_MOVE_ALWAYS ));
if ( iAmountPile > 1 )
{
CItemBase * pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType())
{
if ( iAmountPile == 0 || iAmountPile > GetAmount())
iAmountPile = GetAmount();
pItem->SetAmount( Calc_GetRandVal(iAmountPile) + 1 );
}
}
// pItem->m_uidLink = GetUID(); // This might be dangerous ?
pItem->SetDecayTime( g_Cfg.m_iDecay_Item ); // It will decay eventually to be replaced later.
pItem->MoveNearObj( this, iDistMax );
}