本文整理汇总了C++中CBaseEntity::Activate方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::Activate方法的具体用法?C++ CBaseEntity::Activate怎么用?C++ CBaseEntity::Activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::Activate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ServerActivate
void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
{
int i;
CBaseEntity *pClass;
// ALERT( at_console, "ServerActivate()\n" );
// Every call to ServerActivate should be matched by a call to ServerDeactivate
g_serveractive = 1;
// Clients have not been initialized yet
for ( i = 0; i < edictCount; i++ )
{
if ( pEdictList[i].free )
continue;
// Clients aren't necessarily initialized until ClientPutInServer()
if ( i < clientMax || !pEdictList[i].pvPrivateData )
continue;
pClass = CBaseEntity::Instance( &pEdictList[i] );
// Activate this entity if it's got a class & isn't dormant
if ( pClass && !(pClass->pev->flags & FL_DORMANT) )
{
pClass->Activate();
}
else
{
ALERT( at_console, "Can't instance %s\n", STRING(pEdictList[i].v.classname) );
}
}
// Link user messages here to make sure first client can get them...
LinkUserMessages();
}
示例2: SpawnAllEntities
void SpawnAllEntities( int nEntities, HierarchicalSpawn_t *pSpawnList, bool bActivateEntities )
{
int nEntity;
for (nEntity = 0; nEntity < nEntities; nEntity++)
{
VPROF( "MapEntity_ParseAllEntities_Spawn");
CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;
if ( pSpawnList[nEntity].m_pDeferredParent )
{
// UNDONE: Promote this up to the root of this function?
MDLCACHE_CRITICAL_SECTION();
CBaseEntity *pParent = pSpawnList[nEntity].m_pDeferredParent;
int iAttachment = -1;
CBaseAnimating *pAnim = pParent->GetBaseAnimating();
if ( pAnim )
{
iAttachment = pAnim->LookupAttachment(pSpawnList[nEntity].m_pDeferredParentAttachment);
}
pEntity->SetParent( pParent, iAttachment );
}
if ( pEntity )
{
if (DispatchSpawn(pEntity) < 0)
{
for ( int i = nEntity+1; i < nEntities; i++ )
{
// this is a child object that will be deleted now
if ( pSpawnList[i].m_pEntity && pSpawnList[i].m_pEntity->IsMarkedForDeletion() )
{
pSpawnList[i].m_pEntity = NULL;
}
}
// Spawn failed.
gEntList.CleanupDeleteList();
// Remove the entity from the spawn list
pSpawnList[nEntity].m_pEntity = NULL;
}
}
}
if ( bActivateEntities )
{
VPROF( "MapEntity_ParseAllEntities_Activate");
bool bAsyncAnims = mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, false );
for (nEntity = 0; nEntity < nEntities; nEntity++)
{
CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;
if ( pEntity )
{
MDLCACHE_CRITICAL_SECTION();
pEntity->Activate();
}
}
mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, bAsyncAnims );
}
}
示例3: Build
void CMapzoneEdit::Build(Vector *aimpos, int type, int forcestage)
{
if (mom_zone_grid.GetInt() > 0)
VectorSnapToGrid(aimpos, (float) mom_zone_grid.GetInt());
switch ((forcestage != BUILDSTAGE_NONE) ? forcestage : ++m_nBuildStage)
{
case BUILDSTAGE_START:
m_vecBuildStart = *aimpos;
break;
case BUILDSTAGE_END:
m_vecBuildEnd = *aimpos;
break;
case BUILDSTAGE_HEIGHT:
{
char szClass[64];
if (ZoneTypeToClass(type, szClass))
{
CBaseEntity *pEnt = CreateEntityByName(szClass);
Vector vecOrigin, vecSize, vecMinsRel;
int i;
VectorMin(m_vecBuildStart, m_vecBuildEnd, vecMinsRel);
VectorMax(m_vecBuildStart, m_vecBuildEnd, vecSize);
for (i = 0; i < 3; i++)
vecSize[i] = (vecSize[i] - vecMinsRel[i]) / 2.0f;
for (i = 0; i < 3; i++)
vecOrigin[i] = vecMinsRel[i] + vecSize[i];
pEnt->Spawn();
pEnt->SetAbsOrigin(vecOrigin);
pEnt->SetSize(Vector(-vecSize.x, -vecSize.y, -vecSize.z), vecSize);
pEnt->SetEffects(EF_NODRAW);
pEnt->SetSolid(SOLID_BBOX);
pEnt->Activate();
SetZoneProps(pEnt);
}
}
default:
m_nBuildStage = BUILDSTAGE_NONE;
}
}
示例4: SpawnAlienAt
CBaseEntity* CASW_Spawn_Manager::SpawnAlienAt(const char* szAlienClass, const Vector& vecPos, const QAngle &angle)
{
CBaseEntity *pEntity = NULL;
pEntity = CreateEntityByName( szAlienClass );
CAI_BaseNPC *pNPC = dynamic_cast<CAI_BaseNPC*>(pEntity);
if ( pNPC )
{
pNPC->AddSpawnFlags( SF_NPC_FALL_TO_GROUND );
}
// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
QAngle angles = angle;
angles.x = 0.0;
angles.z = 0.0;
pEntity->SetAbsOrigin( vecPos );
pEntity->SetAbsAngles( angles );
IASW_Spawnable_NPC* pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(pEntity);
ASSERT(pSpawnable);
if ( !pSpawnable )
{
Warning("NULL Spawnable Ent in CASW_Spawn_Manager::SpawnAlienAt! AlienClass = %s\n", szAlienClass);
UTIL_Remove(pEntity);
return NULL;
}
// have drones unburrow by default, so we don't worry so much about them spawning onscreen
if ( !Q_strcmp( szAlienClass, "asw_drone" ) )
{
pSpawnable->StartBurrowed();
pSpawnable->SetUnburrowIdleActivity( NULL_STRING );
pSpawnable->SetUnburrowActivity( NULL_STRING );
}
DispatchSpawn( pEntity );
pEntity->Activate();
// give our aliens the orders
pSpawnable->SetAlienOrders(AOT_MoveToNearestMarine, vec3_origin, NULL);
// reactivedrop: fixed horde aliens falling through floor and stuck in walls
// by moving this function call to the bottom of SpawnAlienAt()
// riflemod: temporary comment to test whether parasites fall throught floor
//UTIL_DropToFloor(pEntity, MASK_SOLID);
return pEntity;
}
示例5: SpawnAlien
IASW_Spawnable_NPC* CASW_Base_Spawner::SpawnAlien( const char *szAlienClassName, const Vector &vecHullMins, const Vector &vecHullMaxs )
{
if ( !IsValidOnThisSkillLevel() )
{
UTIL_Remove(this); // delete ourself if this spawner isn't valid on this difficulty level
return NULL;
}
if ( !CanSpawn( vecHullMins, vecHullMaxs ) ) // this may turn off m_bCurrentlySpawningUber if there's no room
return NULL;
CBaseEntity *pEntity = CreateEntityByName( szAlienClassName );
if ( !pEntity )
{
Msg( "Failed to spawn %s\n", szAlienClassName );
return NULL;
}
CAI_BaseNPC *pNPC = pEntity->MyNPCPointer();
if ( pNPC )
{
pNPC->AddSpawnFlags( SF_NPC_FALL_TO_GROUND );
}
// check if he can see far
if ( m_bLongRangeNPC )
pEntity->AddSpawnFlags( SF_NPC_LONG_RANGE );
if ( HasSpawnFlags( ASW_SF_NEVER_SLEEP ) )
pEntity->AddSpawnFlags( SF_NPC_ALWAYSTHINK );
// Strip pitch and roll from the spawner's angles. Pass only yaw to the spawned NPC.
QAngle angles = GetAbsAngles();
angles.x = 0.0;
angles.z = 0.0;
pEntity->SetAbsOrigin( GetAbsOrigin() );
pEntity->SetAbsAngles( angles );
IASW_Spawnable_NPC* pSpawnable = dynamic_cast<IASW_Spawnable_NPC*>(pEntity);
Assert( pSpawnable );
if ( !pSpawnable )
{
Warning( "NULL Spawnable Ent in asw_spawner! AlienClass = %s\n", szAlienClassName );
UTIL_Remove( pEntity );
return NULL;
}
m_flLastSpawnTime = gpGlobals->curtime;
if ( m_bStartBurrowed )
{
pSpawnable->StartBurrowed();
}
if ( m_bStartBurrowed )
{
pSpawnable->SetUnburrowIdleActivity( m_UnburrowIdleActivity );
pSpawnable->SetUnburrowActivity( m_UnburrowActivity );
}
DispatchSpawn( pEntity );
pEntity->SetOwnerEntity( this );
pEntity->Activate();
if ( m_AlienName != NULL_STRING )
{
pEntity->SetName( m_AlienName );
}
pSpawnable->SetSpawner( this );
RemoveObstructingProps( pEntity );
// give our aliens the orders
pSpawnable->SetAlienOrders( m_AlienOrders, vec3_origin, GetOrderTarget() );
m_OnSpawned.FireOutput(pEntity, this);
return pSpawnable;
}
示例6: SpawnAllEntities
void SpawnAllEntities( int nEntities, HierarchicalSpawn_t *pSpawnList, bool bActivateEntities )
{
#if !defined( _RETAIL )
#if defined( _XBOX )
char sz[ 128 ];
Q_snprintf( sz, sizeof( sz ), "SpawnAllEntities(%d)", nEntities );
XBX_rTimeStampLog( Plat_FloatTime(), sz );
#endif
#endif
int nEntity;
for (nEntity = 0; nEntity < nEntities; nEntity++)
{
VPROF( "MapEntity_ParseAllEntities_Spawn");
CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;
if ( pEntity )
{
if (DispatchSpawn(pEntity) < 0)
{
for ( int i = nEntity+1; i < nEntities; i++ )
{
// this is a child object that will be deleted now
if ( pSpawnList[i].m_pEntity && pSpawnList[i].m_pEntity->IsMarkedForDeletion() )
{
pSpawnList[i].m_pEntity = NULL;
}
}
// Spawn failed.
gEntList.CleanupDeleteList();
// Remove the entity from the spawn list
pSpawnList[nEntity].m_pEntity = NULL;
}
}
}
#if !defined( _RETAIL )
#if defined( _XBOX )
Q_snprintf( sz, sizeof( sz ), "SpawnAllEntities(%d) -activate", nEntities );
XBX_rTimeStampLog( Plat_FloatTime(), sz );
#endif
#endif
if ( bActivateEntities )
{
VPROF( "MapEntity_ParseAllEntities_Activate");
bool bAsyncAnims = mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, false );
for (nEntity = 0; nEntity < nEntities; nEntity++)
{
CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;
if ( pEntity )
{
MDLCACHE_CRITICAL_SECTION();
pEntity->Activate();
}
}
mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, bAsyncAnims );
}
#if !defined( _RETAIL )
#if defined( _XBOX )
Q_snprintf( sz, sizeof( sz ), "SpawnAllEntities(%d) -done activating", nEntities );
XBX_rTimeStampLog( Plat_FloatTime(), sz );
#endif
#endif
}