本文整理汇总了C++中EHANDLE类的典型用法代码示例。如果您正苦于以下问题:C++ EHANDLE类的具体用法?C++ EHANDLE怎么用?C++ EHANDLE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EHANDLE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnlinkChild
//-----------------------------------------------------------------------------
// Purpose: Does the linked list work of removing a child object from the hierarchy.
// Input : pParent -
// pChild -
//-----------------------------------------------------------------------------
void UnlinkChild( CBaseEntity *pParent, CBaseEntity *pChild )
{
CBaseEntity *pList;
EHANDLE *pPrev;
pList = pParent->m_hMoveChild;
pPrev = &pParent->m_hMoveChild;
while ( pList )
{
CBaseEntity *pNext = pList->m_hMovePeer;
if ( pList == pChild )
{
// patch up the list
pPrev->Set( pNext );
// Clear hierarchy bits for this guy
pList->m_hMoveParent.Set( NULL );
pList->m_hMovePeer.Set( NULL );
pList->DispatchUpdateTransmitState();
pList->OnEntityEvent( ENTITY_EVENT_PARENT_CHANGED, NULL );
pParent->RecalcHasPlayerChildBit();
return;
}
else
{
pPrev = &pList->m_hMovePeer;
pList = pNext;
}
}
// This only happens if the child wasn't found in the parent's child list
Assert(0);
}
示例2:
CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEntIndex, int channel,
const char *pSoundName, soundlevel_t soundlevel )
{
CSoundPatch *pSound = new CSoundPatch;
EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL;
pSound->Init( &filter, hEnt.Get(), channel, pSoundName, soundlevel );
return pSound;
}
示例3: LinkChild
void LinkChild( CBaseEntity *pParent, CBaseEntity *pChild )
{
EHANDLE hParent;
hParent.Set( pParent );
pChild->m_hMovePeer.Set( pParent->FirstMoveChild() );
pParent->m_hMoveChild.Set( pChild );
pChild->m_hMoveParent = hParent;
pChild->NetworkProp()->SetNetworkParent( hParent );
pChild->DispatchUpdateTransmitState();
pChild->OnEntityEvent( ENTITY_EVENT_PARENT_CHANGED, NULL );
pParent->RecalcHasPlayerChildBit();
}
示例4: Remove
void CASW_DamageAllocationMgr::Remove( const EHANDLE &handle )
{
IndexType_t i = Find( handle );
if ( IsValid(i) )
{
// strike all projectiles for this target
ProjectilePool_t::IndexLocalType_t j = i->m_nProjectiles;
while ( m_ProjectileLists.IsValidIndex(j) )
{
ProjectilePool_t::IndexLocalType_t old = j;
j = m_ProjectileLists.Next(j);
m_ProjectileLists.Remove( old );
}
int vectoridx = i - m_Targets.Base();
Assert( &m_Targets[vectoridx] == i );
m_Targets.FastRemove( vectoridx );
}
else
{
AssertMsg1( false, "Tried to remove %s from a damage allocation manager whence it was absent.\n",
handle->GetDebugName() );
}
}
示例5: Spawn
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponStriderBuster::Spawn( void )
{
SetModelName( AllocPooledString("models/magnusson_device.mdl") );
BaseClass::Spawn();
// Setup for being shot by the player
m_takedamage = DAMAGE_EVENTS_ONLY;
// Ignore touches until launched.
SetTouch ( NULL );
AddFlag( FL_AIMTARGET|FL_OBJECT );
m_hParticleEffect = CreateEntityByName( "info_particle_system" );
if ( m_hParticleEffect )
{
m_hParticleEffect->KeyValue( "start_active", "1" );
m_hParticleEffect->KeyValue( "effect_name", "striderbuster_smoke" );
DispatchSpawn( m_hParticleEffect );
if ( gpGlobals->curtime > 0.2f )
{
m_hParticleEffect->Activate();
}
m_hParticleEffect->SetAbsOrigin( GetAbsOrigin() );
m_hParticleEffect->SetParent( this );
}
SetHealth( striderbuster_health.GetFloat() );
SetNextThink(gpGlobals->curtime + 0.01f);
}
示例6: SampleVelocity
//-----------------------------------------------------------------------------
// Purpose: Returns the magnitude of the entity's angular velocity.
//-----------------------------------------------------------------------------
void CPointVelocitySensor::SampleVelocity( void )
{
if ( m_hTargetEntity == NULL )
return;
Vector vecVelocity;
if ( m_hTargetEntity->GetMoveType() == MOVETYPE_VPHYSICS )
{
IPhysicsObject *pPhys = m_hTargetEntity->VPhysicsGetObject();
if ( pPhys != NULL )
{
pPhys->GetVelocity( &vecVelocity, NULL );
}
}
else
{
vecVelocity = m_hTargetEntity->GetAbsVelocity();
}
/*
float flSpeed = VectorNormalize( vecVelocity );
float flDot = ( m_vecAxis != vec3_origin ) ? DotProduct( vecVelocity, m_vecAxis ) : 1.0f;
*/
// We want the component of the velocity vector in the direction of the axis, which since the
// axis is normalized is simply their dot product (eg V . A = |V|*|A|*cos(theta) )
m_fPrevVelocity = ( m_vecAxis != vec3_origin ) ? DotProduct( vecVelocity, m_vecAxis ) : 1.0f;
// if it's changed since the last frame, poke the output
if ( m_fPrevVelocity != m_Velocity.Get() )
{
m_Velocity.Set( m_fPrevVelocity, NULL, NULL );
}
}
示例7: PrescheduleThink
void CNPC_Dog::PrescheduleThink( void )
{
BaseClass::PrescheduleThink();
if ( m_hPhysicsEnt )
{
IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();
if ( pPhysObj && pPhysObj->GetGameFlags() & FVPHYSICS_PLAYER_HELD )
{
m_hPhysicsEnt->SetOwnerEntity( NULL );
}
}
if ( m_flTimeToCatch < gpGlobals->curtime )
m_flTimeToCatch = 0.0f;
if ( GetIdealActivity() == ACT_IDLE )
{
if ( m_hPhysicsEnt && m_bHasObject == true )
{
SetIdealActivity( (Activity)ACT_DOG_WAITING );
}
}
}
示例8: FinishCommentary
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CPointCommentaryNode::FinishCommentary( bool bBlendOut )
{
CBasePlayer *pPlayer = GetCommentaryPlayer();
if ( !pPlayer )
return;
// Fire off our postcommands
if ( m_iszPostCommands != NULL_STRING )
{
g_CommentarySystem.SetCommentaryConvarsChanging( true );
engine->ClientCommand( pPlayer->edict(), STRING(m_iszPostCommands) );
engine->ClientCommand( pPlayer->edict(), "commentary_cvarsnotchanging\n" );
}
// Stop the commentary
m_flFinishedTime = gpGlobals->curtime;
if ( bBlendOut && m_hViewPositionMover )
{
m_bActive = false;
m_flPlaybackRate = 1.0;
m_vecFinishOrigin = m_hViewPositionMover->GetAbsOrigin();
m_vecFinishAngles = m_hViewPositionMover->GetAbsAngles();
m_bPreventChangesWhileMoving = true;
// We've moved away from the player's position. Move back to it before ending
SetContextThink( &CPointCommentaryNode::UpdateViewPostThink, gpGlobals->curtime, s_pCommentaryUpdateViewThink );
return;
}
CleanupPostCommentary();
}
示例9: HasRoomToSpawn
//-----------------------------------------------------------------------------
// Purpose: Returns whether or not the template entities can fit if spawned.
// Input : pBlocker - Returns blocker unless NULL.
//-----------------------------------------------------------------------------
bool CEnvEntityMaker::HasRoomToSpawn()
{
// Do we have a blocker from last time?
if ( m_hCurrentBlocker )
{
// If it hasn't moved, abort immediately
if ( m_vecBlockerOrigin == m_hCurrentBlocker->GetAbsOrigin() )
{
return false;
}
}
// Check to see if there's enough room to spawn
trace_t tr;
UTIL_TraceHull( GetAbsOrigin(), GetAbsOrigin(), m_vecEntityMins, m_vecEntityMaxs, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
if ( tr.m_pEnt || tr.startsolid )
{
// Store off our blocker to check later
m_hCurrentBlocker = tr.m_pEnt;
if ( m_hCurrentBlocker )
{
m_vecBlockerOrigin = m_hCurrentBlocker->GetAbsOrigin();
}
return false;
}
return true;
}
示例10: RunTask
void CNPC_GMan::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_WAIT:
// look at who I'm talking to
if (m_flTalkTime > gpGlobals->curtime && m_hTalkTarget != NULL)
{
AddLookTarget( m_hTalkTarget->GetAbsOrigin(), 1.0, 2.0 );
}
// look at player, but only if playing a "safe" idle animation
else if (m_hPlayer != NULL && (GetSequence() == 0 || IsInC5A1()) )
{
AddLookTarget( m_hPlayer->EyePosition(), 1.0, 3.0 );
}
else
{
// Just center the head forward.
Vector forward;
GetVectors( &forward, NULL, NULL );
AddLookTarget( GetAbsOrigin() + forward * 12.0f, 1.0, 1.0 );
SetBoneController( 0, 0 );
}
BaseClass::RunTask( pTask );
break;
}
SetBoneController( 0, 0 );
BaseClass::RunTask( pTask );
}
示例11: CheckSpawnThink
//-----------------------------------------------------------------------------
// Purpose: Check to see if we should spawn another instance
//-----------------------------------------------------------------------------
void CEnvEntityMaker::CheckSpawnThink( void )
{
SetNextThink( gpGlobals->curtime + 0.5f );
// Do we have an instance?
if ( m_hCurrentInstance )
{
// If Wait-For-Destruction is set, abort immediately
if ( m_spawnflags & SF_ENTMAKER_WAITFORDESTRUCTION )
return;
}
// Do we have a blocker?
if ( m_hCurrentBlocker )
{
// If it hasn't moved, abort immediately
if ( m_vecBlockerOrigin == m_hCurrentBlocker->GetAbsOrigin() )
return;
}
// Check to see if there's enough room to spawn
trace_t tr;
UTIL_TraceHull( GetAbsOrigin(), GetAbsOrigin(), m_vecEntityMins, m_vecEntityMaxs, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
if ( tr.m_pEnt || tr.startsolid )
{
// Store off our blocker to check later
m_hCurrentBlocker = tr.m_pEnt;
if ( m_hCurrentBlocker )
{
m_vecBlockerOrigin = m_hCurrentBlocker->GetAbsOrigin();
}
return;
}
// We're clear, now check to see if the player's looking
if ( !(m_spawnflags & SF_ENTMAKER_IGNOREFACING) )
{
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if ( pPlayer )
{
// Only spawn if the player's looking away from me
Vector vLookDir = pPlayer->EyeDirection3D();
Vector vTargetDir = GetAbsOrigin() - pPlayer->EyePosition();
VectorNormalize(vTargetDir);
float fDotPr = DotProduct(vLookDir,vTargetDir);
if ( fDotPr > 0 )
return;
}
}
}
// Clear, no player watching, so spawn!
SpawnEntity();
}
示例12: Spawn
void CPhysicsEntitySolver::Spawn()
{
SetNextThink( gpGlobals->curtime + m_separationDuration );
PhysDisableEntityCollisions( m_hMovingEntity, m_hPhysicsBlocker );
m_savedCollisionGroup = m_hPhysicsBlocker->GetCollisionGroup();
m_hPhysicsBlocker->SetCollisionGroup( COLLISION_GROUP_DEBRIS );
if ( m_hPhysicsBlocker->VPhysicsGetObject() )
{
m_hPhysicsBlocker->VPhysicsGetObject()->RecheckContactPoints();
}
}
示例13: ClientThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_ScriptIntro::ClientThink( void )
{
Assert( m_IntroData.m_Passes.Count() <= 2 );
if ( m_hCameraEntity )
{
m_IntroData.m_vecCameraView = m_hCameraEntity->GetAbsOrigin();
m_IntroData.m_vecCameraViewAngles = m_hCameraEntity->GetAbsAngles();
}
CalculateFOV();
CalculateAlpha();
// Calculate the blend levels of each pass
float flPerc = 1.0;
if ( (m_flNextBlendTime - m_flBlendStartTime) != 0 )
{
flPerc = clamp( (gpGlobals->curtime - m_flBlendStartTime) / (m_flNextBlendTime - m_flBlendStartTime), 0, 1 );
}
// Detect when we're finished blending
if ( flPerc >= 1.0 )
{
if ( m_IntroData.m_Passes.Count() == 2 )
{
// We're done blending
m_IntroData.m_Passes[0].m_BlendMode = m_IntroData.m_Passes[1].m_BlendMode;
m_IntroData.m_Passes[0].m_Alpha = 1.0;
m_IntroData.m_Passes.Remove(1);
//Msg("FINISHED BLEND.\n");
}
return;
}
/*
if ( m_flNextBlendTime >= gpGlobals->curtime )
{
Msg("INTRO BLENDING: Blending from mode %d to %d.\n", m_IntroData.m_Passes[0].m_BlendMode, m_IntroData.m_Passes[1].m_BlendMode );
Msg(" curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, m_flBlendStartTime, m_flNextBlendTime );
Msg(" Perc: %.2f\n", flPerc );
}
*/
if ( m_IntroData.m_Passes.Count() == 2 )
{
m_IntroData.m_Passes[0].m_Alpha = 1.0 - flPerc;
m_IntroData.m_Passes[1].m_Alpha = flPerc;
}
else
{
m_IntroData.m_Passes[0].m_Alpha = 1.0 - flPerc;
}
}
示例14: UpdateViewPostThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPointCommentaryNode::UpdateViewPostThink( void )
{
CBasePlayer *pPlayer = GetCommentaryPlayer();
if ( !pPlayer )
return;
if ( m_hViewPosition.Get() && m_hViewPositionMover )
{
// Blend back to the player's position over time.
float flCurTime = (gpGlobals->curtime - m_flFinishedTime);
float flTimeToBlend = min( 2.0, m_flFinishedTime - m_flStartTime );
float flBlendPerc = 1.0 - clamp( flCurTime / flTimeToBlend, 0, 1 );
//Msg("OUT: CurTime %.2f, BlendTime: %.2f, Blend: %.3f\n", flCurTime, flTimeToBlend, flBlendPerc );
// Only do this while we're still moving
if ( flBlendPerc > 0 )
{
// Figure out the current view position
Vector vecPlayerPos = pPlayer->EyePosition();
Vector vecToPosition = (m_vecFinishOrigin - vecPlayerPos);
Vector vecCurEye = pPlayer->EyePosition() + (vecToPosition * flBlendPerc);
m_hViewPositionMover->SetAbsOrigin( vecCurEye );
if ( m_hViewTarget )
{
Quaternion quatFinish;
Quaternion quatOriginal;
Quaternion quatCurrent;
AngleQuaternion( m_vecOriginalAngles, quatOriginal );
AngleQuaternion( m_vecFinishAngles, quatFinish );
QuaternionSlerp( quatFinish, quatOriginal, 1.0 - flBlendPerc, quatCurrent );
QAngle angCurrent;
QuaternionAngles( quatCurrent, angCurrent );
m_hViewPositionMover->SetAbsAngles( angCurrent );
}
SetNextThink( gpGlobals->curtime, s_pCommentaryUpdateViewThink );
return;
}
pPlayer->SnapEyeAngles( m_hViewPositionMover->GetAbsAngles() );
}
// We're done
CleanupPostCommentary();
m_bPreventChangesWhileMoving = false;
}
示例15: CleanCatchAndThrow
void CNPC_Dog::CleanCatchAndThrow( bool bClearTimers )
{
if ( m_hPhysicsEnt )
{
if ( m_bHasObject == true )
{
IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();
m_hPhysicsEnt->SetParent( NULL );
m_hPhysicsEnt->SetOwnerEntity( NULL );
Vector vGunPos;
QAngle angGunAngles;
GetAttachment( m_iPhysGunAttachment, vGunPos, angGunAngles );
if ( pPhysObj )
{
pPhysObj->Wake();
pPhysObj->RemoveShadowController();
pPhysObj->SetPosition( vGunPos, angGunAngles, true );
}
else
{
Warning( "CleanCatchAndThrow: m_hPhysicsEnt->VPhysicsGetObject == NULL!\n" );
}
m_hPhysicsEnt->SetMoveType( (MoveType_t)m_iContainerMoveType );
if ( pPhysObj )
{
pPhysObj->RecheckCollisionFilter();
}
ClearBeams();
}
m_hPhysicsEnt = NULL;
}
if ( bClearTimers == true )
{
m_bDoCatchThrowBehavior = false;
m_bDoWaitforObjectBehavior = false;
m_flTimeToCatch = 0.0f;
m_flNextSwat = 0.0f;
SetCondition( COND_DOG_LOST_PHYSICS_ENTITY );
}
}