本文整理汇总了C++中TimedEvent类的典型用法代码示例。如果您正苦于以下问题:C++ TimedEvent类的具体用法?C++ TimedEvent怎么用?C++ TimedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
int Update::registerEvent(boost::posix_time::time_duration time, gameplay::EventAction eventAction)
{
boost::lock_guard<boost::mutex> lock(eventMutex);
TimedEvent* event = new TimedEvent(time, eventAction);
event->init();
timedEvents[event->getID()] = event;
return event->getID();
}
示例2: return
/* Call timed event at front of queue, whose time is <= `now'.
* Returns true if an event handler was called. (false if time isn't up yet)
*/
bool TimeQueue::call_timer(uint32 now)
{
if(empty())
return(false);
TimedEvent *tevent = tq.front();
if(tevent->defunct)
{
assert(pop_timer() == tevent);
delete_timer(tevent);
return(false);
}
if(tevent->time > now)
return(false);
//dequeue event here
pop_timer(); // remove timer in case we have recursion in the timed() call.
tevent->timed(now); // fire
//re-queue if repeating timer.
if(tevent->repeat_count != 0) // repeat! same delay, add time
{
// use updated time so it isn't repeated too soon
tevent->set_time();
// tevent->time = clock->get_ticks() + tevent->delay;
// tevent->time = now + tevent->delay;
add_timer(tevent);
if(tevent->repeat_count > 0) // don't reduce count if infinite (-1)
--tevent->repeat_count;
}
else
delete_timer(tevent); // if not repeated, safe to delete
return(true);
}
示例3: OnDataChanged
//-----------------------------------------------------------------------------
// Purpose:
// Input : bnewentity -
//-----------------------------------------------------------------------------
void C_EntityFlame::OnDataChanged( DataUpdateType_t updateType )
{
if ( updateType == DATA_UPDATE_CREATED )
{
SetupEntityRenderHandle( RENDER_GROUP_TRANSLUCENT_ENTITY );
C_BaseEntity *pEnt = m_hEntAttached;
// FIXME: this should be IsBaseAnimating
if (pEnt->IsBaseCombatCharacter())
{
AttachToHitBoxes();
}
else
{
m_ParticleSpawn.Init( 60 ); //Events per second
m_pEmitter = CEmberEffect::Create("C_EntityFlame::Create");
Assert( m_pEmitter.IsValid() );
if ( m_pEmitter.IsValid() )
{
for ( int i = 1; i < NUM_FLAMELETS+1; i++ )
{
m_MaterialHandle[i-1] = m_pEmitter->GetPMaterial( VarArgs( "sprites/flamelet%d", i ) );
}
m_pEmitter->SetSortOrigin( GetAbsOrigin() );
}
}
}
}
示例4: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_Plasma::Update( void )
{
//Update all our parts
UpdateScale();
UpdateAnimation();
UpdateFlames();
if (m_flScaleRegister > 0.1)
{
float tempDelta = gpGlobals->frametime;
while( m_tDecalSpawn.NextEvent( tempDelta ) )
{
// Add decal to floor
C_BaseEntity *ent = cl_entitylist->GetEnt( 0 );
if ( ent )
{
int index = decalsystem->GetDecalIndexForName( "PlasmaGlowFade" );
if ( index >= 0 )
{
effects->DecalShoot( index, 0, ent->GetModel(), ent->GetAbsOrigin(), ent->GetAbsAngles(), GetAbsOrigin(), 0, 0 );
}
}
}
}
}
示例5: Update
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_FireSmoke::Update( void )
{
//If we haven't already, find the clip plane for smoke effects
if ( ( m_nFlags & bitsFIRESMOKE_SMOKE ) && ( m_bClipTested == false ) )
{
FindClipPlane();
}
//Update all our parts
UpdateEffects();
UpdateScale();
UpdateAnimation();
UpdateFlames();
//See if we should emit smoke
if ( m_nFlags & bitsFIRESMOKE_SMOKE )
{
float tempDelta = Helper_GetFrameTime();
while( m_tParticleSpawn.NextEvent( tempDelta ) )
{
SpawnSmoke();
}
}
}
示例6: Start
//-----------------------------------------------------------------------------
// Purpose: Starts the effect
// Input : *pParticleMgr -
// *pArgs -
//-----------------------------------------------------------------------------
void C_SteamJet::Start(CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs)
{
#ifdef GE_DLL
// If the client doesn't want the heat wave effect for explosions disable starting
if ( m_bIsForExplosion && cl_ge_noexpheatwave.GetBool() )
return;
#endif
pParticleMgr->AddEffect( &m_ParticleEffect, this );
switch(m_nType)
{
case STEAM_NORMAL:
default:
m_MaterialHandle = g_Mat_DustPuff[0];
break;
case STEAM_HEATWAVE:
m_MaterialHandle = m_ParticleEffect.FindOrAddMaterial("sprites/heatwave");
break;
}
m_ParticleSpawn.Init(m_Rate);
m_Lifetime = m_JetLength / m_Speed;
m_pParticleMgr = pParticleMgr;
UpdateLightingRamp();
}
示例7: Start
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_ExtinguisherJet::Start( void )
{
SetupEntityRenderHandle( RENDER_GROUP_TRANSLUCENT_ENTITY );
m_ParticleSpawn.Init( 100 ); //Events per second
//Create the basic emitter
m_pEmitter = CSimpleEmitter::Create("C_ExtinguisherJet::m_pEmitter");
Assert( m_pEmitter.IsValid() );
if ( m_pEmitter.IsValid() )
{
m_MaterialHandle = m_pEmitter->GetPMaterial( "particle/particle_smokegrenade" );
m_pEmitter->SetSortOrigin( GetAbsOrigin() );
}
//Create the "ember" emitter for the smaller flecks
m_pEmberEmitter = CEmberEffect::Create( "C_ExtinguisherJet::m_pEmberEmitter" );
Assert( m_pEmberEmitter.IsValid() );
if ( m_pEmberEmitter.IsValid() )
{
m_EmberMaterialHandle = m_pEmberEmitter->GetPMaterial( "particle/particle_smokegrenade" );
m_pEmberEmitter->SetSortOrigin( GetAbsOrigin() );
}
}
示例8: ClientThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_ObjectEMPGenerator::ClientThink( void )
{
// Add particles at the target.
float flCur = gpGlobals->frametime;
while ( m_ParticleEvent.NextEvent( flCur ) )
{
Vector vPos = WorldSpaceCenter( );
Vector vOffset = RandomVector( -1, 1 );
VectorNormalize( vOffset );
vPos += vOffset * RandomFloat( 0, 50 );
SimpleParticle *pParticle = m_pEmitter->AddSimpleParticle( m_hParticleMaterial, vPos );
if ( pParticle )
{
// Move the points along the path.
pParticle->m_vecVelocity.Init();
pParticle->m_flRoll = 0;
pParticle->m_flRollDelta = 0;
pParticle->m_flDieTime = 0.4f;
pParticle->m_flLifetime = 0;
pParticle->m_uchColor[0] = 255;
pParticle->m_uchColor[1] = 255;
pParticle->m_uchColor[2] = 255;
pParticle->m_uchStartAlpha = 32;
pParticle->m_uchEndAlpha = 0;
pParticle->m_uchStartSize = 6;
pParticle->m_uchEndSize = 4;
pParticle->m_iFlags = 0;
}
}
}
示例9: Start
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_ExtinguisherJet::Start( void )
{
AddToLeafSystem( RENDER_GROUP_TRANSLUCENT_ENTITY );
m_ParticleSpawn.Init( 100 ); //Events per second
//Create the basic emitter
m_pEmitter = CSimpleEmitter::Create("C_ExtinguisherJet::m_pEmitter");
Assert( m_pEmitter.IsValid() );
if ( m_pEmitter.IsValid() )
{
m_MaterialHandle = g_Mat_DustPuff[0];
m_pEmitter->SetSortOrigin( GetAbsOrigin() );
}
//Create the "ember" emitter for the smaller flecks
m_pEmberEmitter = CEmberEffect::Create( "C_ExtinguisherJet::m_pEmberEmitter" );
Assert( m_pEmberEmitter.IsValid() );
if ( m_pEmberEmitter.IsValid() )
{
m_EmberMaterialHandle = g_Mat_DustPuff[0];
m_pEmberEmitter->SetSortOrigin( GetAbsOrigin() );
}
}
示例10: Start
//-----------------------------------------------------------------------------
// Purpose: Starts the effect
// Input : *pParticleMgr -
// *pArgs -
//-----------------------------------------------------------------------------
void C_SmokeStack::Start(CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs)
{
pParticleMgr->AddEffect( &m_ParticleEffect, this );
// Figure out the material name.
char str[512] = "unset_material";
const model_t *pModel = modelinfo->GetModel( m_iMaterialModel );
if ( pModel )
{
Q_strncpy( str, modelinfo->GetModelName( pModel ), sizeof( str ) );
// Get rid of the extension because the material system doesn't want it.
char *pExt = Q_stristr( str, ".vmt" );
if ( pExt )
pExt[0] = 0;
}
m_MaterialHandle[0] = m_ParticleEffect.FindOrAddMaterial( str );
int iCount = 1;
char szNames[512];
int iLength = Q_strlen( str );
str[iLength-1] = '\0';
Q_snprintf( szNames, sizeof( szNames ), "%s%d.vmt", str, iCount );
while ( filesystem->FileExists( VarArgs( "materials/%s", szNames ) ) && iCount < SMOKESTACK_MAX_MATERIALS )
{
char *pExt = Q_stristr( szNames, ".vmt" );
if ( pExt )
pExt[0] = 0;
m_MaterialHandle[iCount] = m_ParticleEffect.FindOrAddMaterial( szNames );
iCount++;
}
m_iMaxFrames = iCount-1;
m_ParticleSpawn.Init( mat_reduceparticles.GetBool() ? m_Rate / 4 : m_Rate ); // Obey mat_reduceparticles in episodic
m_InvLifetime = m_Speed / m_JetLength;
m_pParticleMgr = pParticleMgr;
// Figure out how we need to draw.
IMaterial *pMaterial = pParticleMgr->PMaterialToIMaterial( m_MaterialHandle[0] );
if( pMaterial )
{
m_Renderer.Init( pParticleMgr, pMaterial );
}
QueueLightParametersInRenderer();
// For the first N seconds, always simulate so it can build up the smokestack.
// Afterwards, we set it to freeze when it's not being rendered.
m_ParticleEffect.SetAlwaysSimulate( true );
SetNextClientThink( gpGlobals->curtime + 5 );
}
示例11: StartExplosion
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_HopwireExplosion::StartExplosion( void )
{
m_FXCoreScale.Init( 300.0f, 500.0f, 2.0f, INTERP_SPLINE );
m_FXCoreAlpha.Init( 0.0f, 0.1f, 1.5f, INTERP_SPLINE );
// Particle timer
m_ParticleTimer.Init( 60 );
}
示例12: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_SmokeStack::Update(float fTimeDelta)
{
if (!m_pParticleMgr)
{
assert(false);
return;
}
// Don't spawn particles unless we're visible.
if (m_bEmit && (m_ParticleEffect.WasDrawnPrevFrame() || m_ParticleEffect.GetAlwaysSimulate()))
{
// Add new particles.
Vector forward, right, up;
AngleVectors(GetAbsAngles(), &forward, &right, &up);
float tempDelta = fTimeDelta;
while (m_ParticleSpawn.NextEvent(tempDelta))
{
int iRandomFrame = random->RandomInt(0, m_iMaxFrames);
iRandomFrame = 0;
// Make a new particle.
if (SmokeStackParticle *pParticle = (SmokeStackParticle*) m_ParticleEffect.AddParticle(sizeof(SmokeStackParticle), m_MaterialHandle[iRandomFrame]))
{
float angle = FRand(0, 2.0f*M_PI_F);
pParticle->m_Pos = GetAbsOrigin() +
right * (cos(angle) * m_flBaseSpread) +
forward * (sin(angle) * m_flBaseSpread);
pParticle->m_Velocity =
FRand(-m_SpreadSpeed, m_SpreadSpeed) * right +
FRand(-m_SpreadSpeed, m_SpreadSpeed) * forward +
m_Speed * up;
pParticle->m_vAccel = m_vWind;
pParticle->m_Lifetime = 0;
pParticle->m_flAngle = 0.0f;
pParticle->m_flRollDelta = random->RandomFloat(-m_flRollSpeed, m_flRollSpeed);
pParticle->m_flSortPos = pParticle->m_Pos.z;
}
}
}
// Setup the twist matrix.
float flTwist = (m_flTwist * (M_PI_F * 2.f) / 360.0f) * Helper_GetFrameTime();
if ((m_bTwist = !!flTwist))
{
m_TwistMat[0][0] = cos(flTwist);
m_TwistMat[0][1] = sin(flTwist);
m_TwistMat[1][0] = -sin(flTwist);
m_TwistMat[1][1] = cos(flTwist);
}
QueueLightParametersInRenderer();
}
示例13: Start
void C_ParticleFire::Start(CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs)
{
m_pParticleMgr = pParticleMgr;
m_pParticleMgr->AddEffect( &m_ParticleEffect, this );
m_MaterialHandle = m_ParticleEffect.FindOrAddMaterial("particle/particle_fire");
// Start
m_nEmitters = 0;
m_EmitterSpawn.Init(15);
}
示例14: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_EntityParticleTrail::Update( float fTimeDelta )
{
float tempDelta = fTimeDelta;
studiohdr_t *pStudioHdr;
mstudiohitboxset_t *set;
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
C_BaseEntity *pMoveParent = GetMoveParent();
if ( !pMoveParent )
return;
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if (!pAnimating)
goto trailNoHitboxes;
if ( !pAnimating->HitboxToWorldTransforms( hitboxbones ) )
goto trailNoHitboxes;
pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if (!pStudioHdr)
goto trailNoHitboxes;
set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( !set )
goto trailNoHitboxes;
//Add new particles
while ( m_teParticleSpawn.NextEvent( tempDelta ) )
{
int nHitbox = random->RandomInt( 0, set->numhitboxes - 1 );
mstudiobbox_t *pBox = set->pHitbox(nHitbox);
AddParticle( tempDelta, pBox->bbmin, pBox->bbmax, *hitboxbones[pBox->bone] );
}
return;
trailNoHitboxes:
while ( m_teParticleSpawn.NextEvent( tempDelta ) )
{
AddParticle( tempDelta, pMoveParent->CollisionProp()->OBBMins(), pMoveParent->CollisionProp()->OBBMaxs(), pMoveParent->EntityToWorldTransform() );
}
}
示例15: OnDataChanged
//-----------------------------------------------------------------------------
// Purpose:
// Input : updateType -
//-----------------------------------------------------------------------------
void C_AlyxEmpEffect::OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
if ( updateType == DATA_UPDATE_CREATED )
{
m_tParticleSpawn.Init( 32 );
SetNextClientThink( CLIENT_THINK_ALWAYS );
SetupEmitters();
}
}