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


C++ CTFPlayer::GetObjectCount方法代码示例

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


在下文中一共展示了CTFPlayer::GetObjectCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindMatch

CObjectTeleporter* CObjectTeleporter::FindMatch( void )
{
    int iObjType = GetType();
    int iOppositeType = ( iObjType == OBJ_TELEPORTER_ENTRANCE ) ? OBJ_TELEPORTER_EXIT : OBJ_TELEPORTER_ENTRANCE;

    CObjectTeleporter *pMatch = NULL;

    CTFPlayer *pBuilder = GetBuilder();

    Assert( pBuilder );

    if ( !pBuilder )
    {
        return NULL;
    }

    int i;
    int iNumObjects = pBuilder->GetObjectCount();
    for ( i=0;i<iNumObjects;i++ )
    {
        CBaseObject *pObj = pBuilder->GetObject(i);

        if ( pObj && pObj->GetType() == iOppositeType && !pObj->IsDisabled() )
        {
            pMatch = ( CObjectTeleporter * )pObj;
            break;
        }
    }

    return pMatch;
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:31,代码来源:tf_obj_teleporter.cpp

示例2: FindMatch

CObjectTeleporter* CObjectTeleporter::FindMatch( void )
{
    int iObjMode = GetObjectMode();
    int iOppositeMode = ( iObjMode == TELEPORTER_TYPE_ENTRANCE ) ? TELEPORTER_TYPE_EXIT : TELEPORTER_TYPE_ENTRANCE;

    CObjectTeleporter *pMatch = NULL;

    CTFPlayer *pBuilder = GetBuilder();

    if ( !pBuilder )
    {
        return NULL;
    }

    int i;
    int iNumObjects = pBuilder->GetObjectCount();
    for ( i=0;i<iNumObjects;i++ )
    {
        CBaseObject *pObj = pBuilder->GetObject(i);

        if ( pObj && pObj->GetType() == GetType() && pObj->GetObjectMode() == iOppositeMode && !pObj->IsDisabled() )
        {
            pMatch = ( CObjectTeleporter * )pObj;

            // Copy upgrade state from higher level end.
            bool bCopyFrom = pMatch->GetUpgradeLevel() > GetUpgradeLevel();
            if ( pMatch->GetUpgradeLevel() == GetUpgradeLevel() )
            {
                // If same level use it if it has more metal.
                bCopyFrom = pMatch->m_iUpgradeMetal > m_iUpgradeMetal;
            }
            CopyUpgradeStateToMatch( pMatch, bCopyFrom );
            break;
        }
    }

    return pMatch;
}
开发者ID:Deathreus,项目名称:TF2Classic,代码行数:38,代码来源:tf_obj_teleporter.cpp

示例3: ReapplyProvision

void CTFPowerupBottle::ReapplyProvision()
{
    CTFWearable::ReapplyProvision();
    
    CBaseEntity *owner = this->GetOwnerEntity();
    if (owner == nullptr) {
        return;
    }
    
    IHasAttributes *owner_ihasattr = owner->GetHasAttributesInterfacePtr();
    if (owner_ihasattr == nullptr) {
        return;
    }
    
    if (this->m_bActive) {
        if (!owner_ihasattr->GetAttributeManager()->IsBeingProvidedToBy(this)) {
            this->GetAttributeManager()->ProvideTo(owner);
        }
    } else {
        this->GetAttributeManager()->StopProvidingTo(owner);
    }
    
    CTFPlayer *player = dynamic_cast<CTFPlayer *>(owner);
    if (player == nullptr) {
        return;
    }
    
    /* BUG: because "canteen_specialist" is an integer attribute, the call to
     * AttribHookValue<int> will truncate any fractional part of the powerup
     * duration */
    float duration = CAttributeManager::AttribHookValue<float>(0.0f,
        "powerup_duration", this, nullptr, true);
    duration = CAttributeManager::AttribHookValue<int>((int)duration,
        "canteen_specialist", player, nullptr, true);
    
    CTFPlayer *share_with = nullptr;
    int share_attr = 0;
    
    if (player->IsPlayerClass(TF_CLASS_MEDIC)) {
        CTFWeaponBase *weapon = player->GetActiveWeapon();
        if (weapon != nullptr) {
            CWeaponMedigun *medigun = dynamic_cast<CWeaponMedigun *>(weapon);
            if (medigun != nullptr) {
                share_with = ToTFPlayer(medigun->GetHealTarget());
                if (share_with != nullptr) {
                    share_attr = CAttributeManager::AttribHookValue<int>(0,
                        "canteen_specialist", player, nullptr, true);
                }
            }
        }
    }
    
    bool did_share = false;
    
    if (CAttributeManager::AttribHookValue<int>(0, "critboost",
        this, nullptr, true) != 0) {
        if (this->m_bActive) {
            player->m_Shared.AddCond(TF_COND_CRITBOOSTED_USER_BUFF, duration);
            
            if (share_with != nullptr && share_attr != 0) {
                share_with->m_Shared.AddCond(TF_COND_CRITBOOSTED_USER_BUFF,
                    duration);
                did_share = true;
            }
        } else {
            player->m_Shared.RemoveCond(TF_COND_CRITBOOSTED_USER_BUFF, true);
        }
    }
    
    if (CAttributeManager::AttribHookValue<int>(0, "ubercharge",
        this, nullptr, true) != 0) {
        if (this->m_bActive) {
            player->m_Shared.AddCond(TF_COND_INVULNERABLE_USER_BUFF, duration);
            
            if (player->IsPlayerClass(TF_CLASS_ENGINEER)) {
                int obj_count = player->GetObjectCount();
                if (obj_count > 0) {
                    for (int i = obj_count - 1; i != -1; --i) {
                        CBaseObject *obj = player->GetObject(i);
                        if (obj != nullptr) {
                            CObjectSentrygun *sentry = dynamic_cast<CObjectSentrygun *>(obj);
                            if (sentry != nullptr && !sentry->m_bCarried) {
                                sentry->m_nShieldLevel = 2;
                                // TODO: set float @ CObjectSentrygun+0xb14
                                // to gpGlobals->curtime + duration
                            }
                        }
                    }
                }
            } else if (share_with != nullptr && share_attr != 0) {
                share_with->m_Shared.AddCond(TF_COND_INVULNERABLE_USER_BUFF,
                    duration);
                did_share = true;
            }
        } else {
            player->m_Shared.RemoveCond(TF_COND_INVULNERABLE_USER_BUFF, true);
        }
    }
    
    if (CAttributeManager::AttribHookValue<int>(0, "recall",
//.........这里部分代码省略.........
开发者ID:Msalinas2877,项目名称:mvm-reversed,代码行数:101,代码来源:tf_item_powerup_bottle.cpp


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