本文整理汇总了C++中CBaseCombatWeapon::IsEffectActive方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon::IsEffectActive方法的具体用法?C++ CBaseCombatWeapon::IsEffectActive怎么用?C++ CBaseCombatWeapon::IsEffectActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatWeapon
的用法示例。
在下文中一共展示了CBaseCombatWeapon::IsEffectActive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Think
//---------------------------------------------------------
// Count of all the weapons in the world of my type and
// see if we have a surplus. If there is a surplus, try
// to find suitable candidates for removal.
//
// Right now we just remove the first weapons we find that
// are behind the player, or are out of the player's PVS.
// Later, we may want to score the results so that we
// removed the farthest gun that's not in the player's
// viewcone, etc.
//
// Some notes and thoughts:
//
// This code is designed NOT to remove weapons that are
// hand-placed by level designers. It should only clean
// up weapons dropped by dead NPCs, which is useful in
// situations where enemies are spawned in for a sustained
// period of time.
//
// Right now we PREFER to remove weapons that are not in the
// player's PVS, but this could be opposite of what we
// really want. We may only want to conduct the cleanup on
// weapons that are IN the player's PVS.
//---------------------------------------------------------
void CGameWeaponManager::Think()
{
int i;
// Don't have to think all that often.
SetNextThink( gpGlobals->curtime + 2.0 );
const char *pszWeaponName = STRING( m_iszWeaponName );
CUtlVector<CBaseEntity *> candidates( 0, 64 );
if ( m_bExpectingWeapon )
{
CBaseCombatWeapon *pWeapon = NULL;
// Firstly, count the total number of weapons of this type in the world.
// Also count how many of those can potentially be removed.
pWeapon = assert_cast<CBaseCombatWeapon *>(gEntList.FindEntityByClassname( pWeapon, pszWeaponName ));
while( pWeapon )
{
if( !pWeapon->IsEffectActive( EF_NODRAW ) && pWeapon->IsRemoveable() )
{
candidates.AddToTail( pWeapon );
}
pWeapon = assert_cast<CBaseCombatWeapon *>(gEntList.FindEntityByClassname( pWeapon, pszWeaponName ));
}
}
else
{
for ( i = 0; i < m_ManagedNonWeapons.Count(); i++)
{
CBaseEntity *pEntity = m_ManagedNonWeapons[i];
if ( pEntity )
{
Assert( pEntity->m_iClassname == m_iszWeaponName );
if ( !pEntity->IsEffectActive( EF_NODRAW ) )
{
candidates.AddToTail( pEntity );
}
}
else
{
m_ManagedNonWeapons.FastRemove( i-- );
}
}
}
// Calculate the surplus.
int surplus = candidates.Count() - m_iMaxPieces;
// Based on what the player can see, try to clean up the world by removing weapons that
// the player cannot see right at the moment.
CBaseEntity *pCandidate;
for ( i = 0; i < candidates.Count() && surplus > 0; i++ )
{
bool fRemovedOne = false;
pCandidate = candidates[i];
Assert( !pCandidate->IsEffectActive( EF_NODRAW ) );
// if ( gpGlobals->maxClients == 1 )
{
CBasePlayer *pPlayer = UTIL_GetNearestVisiblePlayer(pCandidate);
// Nodraw serves as a flag that this weapon is already being removed since
// all we're really doing inside this loop is marking them for removal by
// the entity system. We don't want to count the same weapon as removed
// more than once.
if( !UTIL_FindClientInPVS( pCandidate->edict() ) )
{
fRemovedOne = true;
}
else if( !pPlayer->FInViewCone( pCandidate ) )
{
fRemovedOne = true;
}
//.........这里部分代码省略.........