本文整理汇总了C++中CBaseFilter::PassesFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseFilter::PassesFilter方法的具体用法?C++ CBaseFilter::PassesFilter怎么用?C++ CBaseFilter::PassesFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseFilter
的用法示例。
在下文中一共展示了CBaseFilter::PassesFilter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PassesFilterImpl
//-----------------------------------------------------------------------------
// Purpose: Returns true if the entity passes our filter, false if not.
// Input : pEntity - Entity to test.
//-----------------------------------------------------------------------------
bool CFilterMultiple::PassesFilterImpl( CBaseEntity *pCaller, CBaseEntity *pEntity )
{
// Test against each filter
if (m_nFilterType == FILTER_AND)
{
for (int i=0;i<MAX_FILTERS;i++)
{
if (m_hFilter[i] != NULL)
{
CBaseFilter* pFilter = (CBaseFilter *)(m_hFilter[i].Get());
if (!pFilter->PassesFilter( pCaller, pEntity ) )
{
return false;
}
}
}
return true;
}
else // m_nFilterType == FILTER_OR
{
for (int i=0;i<MAX_FILTERS;i++)
{
if (m_hFilter[i] != NULL)
{
CBaseFilter* pFilter = (CBaseFilter *)(m_hFilter[i].Get());
if (pFilter->PassesFilter( pCaller, pEntity ) )
{
return true;
}
}
}
return false;
}
}
示例2: FindByRandom
void CPointEntityFinder::FindByRandom( void )
{
// TODO: optimize the case where there is no filter
m_hEntity = NULL;
CBaseFilter *pFilter = m_hFilter.Get();
CUtlVector<CBaseEntity *> ValidEnts;
CBaseEntity *pEntity = gEntList.FirstEnt();
do // note all valid entities.
{
if ( pFilter && pFilter->PassesFilter( this, pEntity ) )
{
ValidEnts.AddToTail( pEntity );
}
pEntity = gEntList.NextEnt( pEntity );
} while ( pEntity );
// pick one at random
if ( ValidEnts.Count() != 0 )
{
m_hEntity = ValidEnts[ RandomInt( 0, ValidEnts.Count() - 1 )];
}
}
示例3: EntityPassesFilter
bool CFuncVPhysicsClip::EntityPassesFilter( CBaseEntity *pOther )
{
CBaseFilter* pFilter = (CBaseFilter*)(m_hFilter.Get());
if ( pFilter )
return pFilter->PassesFilter( this, pOther );
if ( pOther->GetMoveType() == MOVETYPE_VPHYSICS && pOther->VPhysicsGetObject()->IsMoveable() )
return true;
return false;
}
示例4: PassesTouchFilters
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CEnvBeam::PassesTouchFilters(CBaseEntity *pOther)
{
bool fPassedSoFar = false;
// Touched some player or NPC!
if( m_TouchType != touch_npc_only )
{
if( pOther->IsPlayer() )
{
fPassedSoFar = true;
}
}
if( m_TouchType != touch_player_only )
{
if( pOther->IsNPC() )
{
fPassedSoFar = true;
}
}
if( m_TouchType == touch_player_or_npc_or_physicsprop )
{
if( pOther->m_iClassname == g_iszPhysicsPropClassname )
{
fPassedSoFar = true;
}
}
if( fPassedSoFar )
{
CBaseFilter* pFilter = (CBaseFilter*)(m_hFilter.Get());
return (!pFilter) ? true : pFilter->PassesFilter( this, pOther );
}
return false;
}
示例5: CanHearSound
//-----------------------------------------------------------------------------
// Purpose: Checks whether this microphone can hear a given sound, and at what
// relative volume level.
// Input : pSound - Sound to test.
// flVolume - Returns with the relative sound volume from 0 - 1.
// Output : Returns true if the sound could be heard at the sample point, false if not.
//-----------------------------------------------------------------------------
bool CEnvMicrophone::CanHearSound(CSound *pSound, float &flVolume)
{
flVolume = 0;
if ( m_bDisabled )
{
return false;
}
// Cull out sounds except from specific entities
CBaseFilter *pFilter = m_hListenFilter.Get();
if ( pFilter )
{
CBaseEntity *pSoundOwner = pSound->m_hOwner.Get();
if ( !pSoundOwner || !pFilter->PassesFilter( this, pSoundOwner ) )
{
return false;
}
}
float flDistance = (pSound->GetSoundOrigin() - m_hMeasureTarget->GetAbsOrigin()).Length();
if (flDistance == 0)
{
flVolume = 1.0;
return true;
}
// Over our max range?
if ( m_flMaxRange && flDistance > m_flMaxRange )
{
return false;
}
if (flDistance <= pSound->Volume() * m_flSensitivity)
{
flVolume = 1 - (flDistance / (pSound->Volume() * m_flSensitivity));
flVolume = clamp(flVolume, 0, 1);
return true;
}
return false;
}
示例6: PassesBlockTouchFilter
bool CBaseDoor::PassesBlockTouchFilter(CBaseEntity *pOther)
{
CBaseFilter* pFilter = (CBaseFilter*)(m_hBlockFilter.Get());
return ( pFilter && pFilter->PassesFilter( this, pOther ) );
}
示例7: FindByDistance
void CPointEntityFinder::FindByDistance( void )
{
m_hEntity = NULL;
CBaseFilter *pFilter = m_hFilter.Get();
// go through each entity and determine whether it's closer or farther from the current entity. Pick according to Method selected.
float flBestDist = 0;
CBaseEntity *pEntity = gEntList.FirstEnt();
while ( pEntity )
{
if ( FStrEq( STRING( pEntity->m_iClassname ), "worldspawn" )
|| FStrEq( STRING( pEntity->m_iClassname ), "soundent" )
|| FStrEq( STRING( pEntity->m_iClassname ), "player_manager" )
|| FStrEq( STRING( pEntity->m_iClassname ), "bodyque" )
|| FStrEq( STRING( pEntity->m_iClassname ), "ai_network" )
|| pEntity == this
|| ( pFilter && !( pFilter->PassesFilter( this, pEntity ) ) ) )
{
pEntity = gEntList.NextEnt( pEntity );
continue;
}
// if we have a reference entity, use that, otherwise, check against 'this'
Vector vecStart;
if ( m_hReference )
{
vecStart = m_hReference->GetAbsOrigin();
}
else
{
vecStart = GetAbsOrigin();
}
// init m_hEntity with a valid entity.
if (m_hEntity == NULL )
{
m_hEntity = pEntity;
flBestDist = ( pEntity->GetAbsOrigin() - vecStart ).LengthSqr();
}
float flNewDist = ( pEntity->GetAbsOrigin() - vecStart ).LengthSqr();
switch ( m_FindMethod )
{
case ( ENT_FIND_METHOD_NEAREST ):
if ( flNewDist < flBestDist )
{
m_hEntity = pEntity;
flBestDist = flNewDist;
}
break;
case ( ENT_FIND_METHOD_FARTHEST ):
if ( flNewDist > flBestDist )
{
m_hEntity = pEntity;
flBestDist = flNewDist;
}
break;
default:
Assert( false );
break;
}
pEntity = gEntList.NextEnt( pEntity );
}
}