本文整理汇总了C++中CGlobalEntityList类的典型用法代码示例。如果您正苦于以下问题:C++ CGlobalEntityList类的具体用法?C++ CGlobalEntityList怎么用?C++ CGlobalEntityList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGlobalEntityList类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//-----------------------------------------------------------------------------
// Purpose: Finds the first entity within radius distance by class name.
// Input : pStartEntity - The entity to start from when doing the search.
// szName - Entity class name, ie "info_target".
// vecSrc - Center of search radius.
// flRadius - Search radius for classname search, 0 to search everywhere.
// Output : Returns a pointer to the found entity, NULL if none.
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityByClassnameWithin( CBaseEntity *pStartEntity, const char *szName, const Vector &vecSrc, float flRadius )
{
//
// Check for matching class names within the search radius.
//
CBaseEntity *pEntity = pStartEntity;
float flMaxDist2 = flRadius * flRadius;
if (flMaxDist2 == 0)
{
return gEntList.FindEntityByClassname( pEntity, szName );
}
while ((pEntity = gEntList.FindEntityByClassname( pEntity, szName )) != NULL)
{
if ( !pEntity->edict() )
continue;
float flDist2 = (pEntity->GetAbsOrigin() - vecSrc).LengthSqr();
if (flMaxDist2 > flDist2)
{
return pEntity;
}
}
return NULL;
}
示例2:
//-----------------------------------------------------------------------------
// Purpose: Finds the first entity by target name or class name within a radius
// Input : pStartEntity - The entity to start from when doing the search.
// szName - Entity name to search for. Treated as a target name first,
// then as an entity class name, ie "info_target".
// vecSrc - Center of search radius.
// flRadius - Search radius for classname search, 0 to search everywhere.
// pSearchingEntity - The entity that is doing the search.
// pActivator - The activator entity if this was called from an input
// or Use handler, NULL otherwise.
// Output : Returns a pointer to the found entity, NULL if none.
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityGenericWithin( CBaseEntity *pStartEntity, const char *szName, const Vector &vecSrc, float flRadius, CBaseEntity *pSearchingEntity, CBaseEntity *pActivator, CBaseEntity *pCaller, int brushPrecision )
{
CBaseEntity *pEntity = NULL;
pEntity = gEntList.FindEntityByNameWithin( pStartEntity, szName, vecSrc, flRadius, pSearchingEntity, pActivator, pCaller, brushPrecision );
if (!pEntity)
{
pEntity = gEntList.FindEntityByClassnameWithin( pStartEntity, szName, vecSrc, flRadius, brushPrecision );
}
return pEntity;
}
示例3: SceneManager_ClientActive
#include "globalstate.h"
#include "datacache/imdlcache.h"
#ifdef HL2_DLL
#include "npc_playercompanion.h"
#endif // HL2_DLL
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
CBaseEntity *FindPickerEntity( CBasePlayer *pPlayer );
void SceneManager_ClientActive( CBasePlayer *player );
static CUtlVector<IServerNetworkable*> g_DeleteList;
CGlobalEntityList gEntList;
CBaseEntityList *g_pEntityList = &gEntList;
class CAimTargetManager : public IEntityListener
{
public:
// Called by CEntityListSystem
void LevelInitPreEntity()
{
gEntList.AddListenerEntity( this );
Clear();
}
void LevelShutdownPostEntity()
{
gEntList.RemoveListenerEntity( this );
Clear();
示例4: FrameUpdatePostEntityThink
void FrameUpdatePostEntityThink()
{
g_TouchManager.FrameUpdatePostEntityThink();
if ( m_bRespawnAllEntities )
{
m_bRespawnAllEntities = false;
// Don't change globalstate owing to deletion here
GlobalEntity_EnableStateUpdates( false );
// Remove all entities
int nPlayerIndex = -1;
CBaseEntity *pEnt = gEntList.FirstEnt();
while ( pEnt )
{
CBaseEntity *pNextEnt = gEntList.NextEnt( pEnt );
if ( pEnt->IsPlayer() )
{
nPlayerIndex = pEnt->entindex();
}
if ( !pEnt->IsEFlagSet( EFL_KEEP_ON_RECREATE_ENTITIES ) )
{
UTIL_Remove( pEnt );
}
pEnt = pNextEnt;
}
gEntList.CleanupDeleteList();
GlobalEntity_EnableStateUpdates( true );
// Allows us to immediately re-use the edict indices we just freed to avoid edict overflow
engine->AllowImmediateEdictReuse();
// Reset node counter used during load
CNodeEnt::m_nNodeCount = 0;
CRespawnEntitiesFilter filter;
MapEntity_ParseAllEntities( engine->GetMapEntitiesString(), &filter, true );
// Allocate a CBasePlayer for pev, and call spawn
if ( nPlayerIndex >= 0 )
{
edict_t *pEdict = engine->PEntityOfEntIndex( nPlayerIndex );
ClientPutInServer( pEdict, "unnamed" );
ClientActive( pEdict, false );
CBasePlayer *pPlayer = ( CBasePlayer * )CBaseEntity::Instance( pEdict );
SceneManager_ClientActive( pPlayer );
}
}
}
示例5: ListCopy
int ListCopy( CBaseEntity *pList[], int listMax )
{
int count = MIN(listMax, ListCount());
for ( int i = 0; i < count; i++ )
{
int entinfoIndex = m_simThinkList[i];
const CEntInfo *pInfo = gEntList.GetEntInfoPtrByIndex( entinfoIndex );
pList[i] = (CBaseEntity *)pInfo->m_pEntity;
Assert( gEntList.IsEntityPtr( pList[i] ) );
}
return count;
}
示例6: ForceRepopulateList
void ForceRepopulateList()
{
Clear();
CBaseEntity *pEnt = gEntList.FirstEnt();
while( pEnt )
{
if( ShouldAddEntity(pEnt) )
AddEntity(pEnt);
pEnt = gEntList.NextEnt( pEnt );
}
}
示例7: ListCopy
int ListCopy( CBaseEntity *pList[], int listMax )
{
int count = MIN(listMax, ListCount());
int out = 0;
for ( int i = 0; i < count; i++ )
{
// only copy out entities that will simulate or think this frame
if ( m_simThinkList[i].nextThinkTick <= gpGlobals->tickcount )
{
Assert(m_simThinkList[i].nextThinkTick>=0);
int entinfoIndex = m_simThinkList[i].entEntry;
const CEntInfo *pInfo = gEntList.GetEntInfoPtrByIndex( entinfoIndex );
pList[out] = (CBaseEntity *)pInfo->m_pEntity;
Assert(m_simThinkList[i].nextThinkTick==0 || pList[out]->GetFirstThinkTick()==m_simThinkList[i].nextThinkTick);
Assert( gEntList.IsEntityPtr( pList[out] ) );
out++;
}
}
return out;
}
示例8: PostClientMessagesSent
void PostClientMessagesSent()
{
for ( int i = m_list.Count()-1; i >= 0; --i )
{
CBaseEntity *pEntity = (CBaseEntity *)gEntList.GetEntInfoPtrByIndex( m_list[i] )->m_pEntity;
if ( pEntity )
{
pEntity->PostClientMessagesSent();
}
}
m_list.RemoveAll();
}
示例9: LevelShutdownPostEntity
void LevelShutdownPostEntity()
{
gEntList.RemoveListenerEntity( this );
Clear();
}
示例10: LevelInitPreEntity
// Called by CEntityListSystem
void LevelInitPreEntity()
{
gEntList.AddListenerEntity( this );
Clear();
}
示例11: LevelShutdownPreEntity
void CNotifyList::LevelShutdownPreEntity( void )
{
gEntList.RemoveListenerEntity( this );
m_notifyList.Purge();
}