当前位置: 首页>>代码示例>>C++>>正文


C++ CItemBase::IsStackableType方法代码示例

本文整理汇总了C++中CItemBase::IsStackableType方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemBase::IsStackableType方法的具体用法?C++ CItemBase::IsStackableType怎么用?C++ CItemBase::IsStackableType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CItemBase的用法示例。


在下文中一共展示了CItemBase::IsStackableType方法的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());
}
开发者ID:DarkLotus,项目名称:Source,代码行数:30,代码来源:CItemSpawn.cpp

示例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();
}
开发者ID:leandrorenato,项目名称:Source,代码行数:43,代码来源:CItemSpawn.cpp

示例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 );
}
开发者ID:GenerationOfWorlds,项目名称:Sphere,代码行数:61,代码来源:CItemSp.cpp


注:本文中的CItemBase::IsStackableType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。