本文整理汇总了C++中BecomeActive函数的典型用法代码示例。如果您正苦于以下问题:C++ BecomeActive函数的具体用法?C++ BecomeActive怎么用?C++ BecomeActive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BecomeActive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveShard
/*
================
idBrittleFracture::Think
================
*/
void idBrittleFracture::Think( void ) {
int i, startTime, endTime, droppedTime;
shard_t *shard;
bool atRest = true, fading = false;
// remove overdue shards
for( i = 0; i < shards.Num(); i++ ) {
droppedTime = shards[i]->droppedTime;
if( droppedTime != -1 ) {
if( gameLocal.time - droppedTime > SHARD_ALIVE_TIME ) {
RemoveShard( i );
i--;
}
fading = true;
}
}
// remove the entity when nothing is visible
if( !shards.Num() ) {
PostEventMS( &EV_Remove, 0 );
return;
}
if( thinkFlags & TH_PHYSICS ) {
startTime = gameLocal.previousTime;
endTime = gameLocal.time;
// run physics on shards
for( i = 0; i < shards.Num(); i++ ) {
shard = shards[i];
if( shard->droppedTime == -1 ) {
continue;
}
shard->physicsObj.Evaluate( endTime - startTime, endTime );
if( !shard->physicsObj.IsAtRest() ) {
atRest = false;
}
}
if( atRest ) {
BecomeInactive( TH_PHYSICS );
} else {
BecomeActive( TH_PHYSICS );
}
}
if( !atRest || bounds.IsCleared() ) {
bounds.Clear();
for( i = 0; i < shards.Num(); i++ ) {
bounds.AddBounds( shards[i]->clipModel->GetAbsBounds() );
}
}
if( fading ) {
BecomeActive( TH_UPDATEVISUALS | TH_THINK );
} else {
BecomeInactive( TH_THINK );
}
RunPhysics();
Present();
}
示例2: InitCollisionInfo
END_CLASS
/*
=================
hhProjectileCrawlerGrenade::Spawn
=================
*/
void hhProjectileCrawlerGrenade::Spawn() {
modelScale.Init( gameLocal.time, 0, 1.0f, 1.0f );
modelProxy = NULL;
InitCollisionInfo();
//doesn't matter for single player, only for network logic -rww
modelProxyCopyDone = false;
if( !gameLocal.isClient ) {
SpawnModelProxy();
}
BecomeActive( TH_TICKER );
if (gameLocal.isClient)
{ //rww - do this right away on the client
//Get rid of our model. The modelProxy is our model now.
SetModel( "" );
}
//rww - allow events on client
fl.clientEvents = true;
}
示例3: switch
//--------------------------------
// hhProxDoor::SetDoorState
//--------------------------------
void hhProxDoor::SetDoorState( EProxState doorState ) {
int i;
//HUMANHEAD PCF mdl 04/27/06 - Don't allow locked doors to become active
if ( doorLocked && doorState == PROXSTATE_Active ) {
return;
}
switch( doorState ) {
case PROXSTATE_Active:
BecomeActive( TH_TICKER );
CancelEvents( &EV_PollForExit );
PostEventMS( &EV_PollForExit, 500 );
OpenPortal();
break;
case PROXSTATE_GoingInactive:
break;
case PROXSTATE_Inactive:
// Guarantee the door is closed
for( i = 0; i < doorPieces.Num(); i++ ) {
if (doorPieces[i].IsValid()) {
doorPieces[ i ]->SetProximity( 0.0 );
}
}
ClosePortal();
CancelEvents( &EV_PollForExit );
BecomeInactive( TH_TICKER );
break;
}
proxState = doorState;
}
示例4: BecomeActive
void idWorldManager::Spawn( void )
{
int i;
for (i = 0; i < 3; i++)
{
idDict args;
records[i].index = 0;
records[i].playing = false;
records[i].completed = false;
args.Clear();
args.Set( "model", "models/monster_npc/tris.ase" );
args.SetInt( "solid", 0 );
args.Set("skin", "skins/npc/ghost2");
records[i].ghost = ( idMover * )gameLocal.SpawnEntityType( idMover::Type, &args );
records[i].ghost->Hide();
recordlines[i].lines.Clear();
}
lastPosition = vec3_zero;
lastAngle = 0;
nextRecordtime = 0;
recordStarttime = 0;
index = 0;
state = OFF;
BecomeActive( TH_THINK );
}
示例5: at
/*
================
idSound::Spawn
================
*/
void idSound::Spawn( void )
{
spawnArgs.GetVector( "move", "0 0 0", shakeTranslate );
spawnArgs.GetAngles( "rotate", "0 0 0", shakeRotate );
spawnArgs.GetFloat( "random", "0", random );
spawnArgs.GetFloat( "wait", "0", wait );
if( ( wait > 0.0f ) && ( random >= wait ) )
{
random = wait - 0.001;
gameLocal.DWarning( "speaker '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString( 0 ) );
}
soundVol = 0.0f;
lastSoundVol = 0.0f;
if( ( shakeRotate != ang_zero ) || ( shakeTranslate != vec3_zero ) )
{
BecomeActive( TH_THINK );
}
if( !refSound.waitfortrigger && ( wait > 0.0f ) )
{
timerOn = true;
PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random );
}
else
{
timerOn = false;
}
}
示例6: memset
/*
================
idExplodingBarrel::AddLight
================
*/
void idExplodingBarrel::AddLight( const char *name, bool burn ) {
if ( lightHandle >= 0 ){
gameRenderWorld->FreeLightDef( lightHandle );
}
memset( &light, 0, sizeof ( light ) );
light.axis = mat3_identity;
light.lightRadius.x = spawnArgs.GetFloat( "light_radius" );
light.lightRadius.y = light.lightRadius.z = light.lightRadius.x;
light.origin = physicsObj.GetOrigin();
light.origin.z += 128;
light.pointLight = true;
// RAVEN BEGIN
// dluetscher: added detail levels to render lights
light.detailLevel = DEFAULT_LIGHT_DETAIL_LEVEL;
// dluetscher: made sure that barrels are set to no shadows
light.noShadows = true;
// RAVEN END
light.shader = declManager->FindMaterial( name );
light.shaderParms[ SHADERPARM_RED ] = 2.0f;
light.shaderParms[ SHADERPARM_GREEN ] = 2.0f;
light.shaderParms[ SHADERPARM_BLUE ] = 2.0f;
light.shaderParms[ SHADERPARM_ALPHA ] = 2.0f;
lightHandle = gameRenderWorld->AddLightDef( &light );
lightTime = gameLocal.time;
BecomeActive( TH_THINK );
}
示例7: idClipModel
void rvVehicleSpline::Spawn ( void ) {
physicsObj.SetSelf( this );
physicsObj.SetClipModel( new idClipModel(GetPhysics()->GetClipModel()), 1.0f );
physicsObj.SetContents( CONTENTS_SOLID );
physicsObj.SetClipMask( 0 );
physicsObj.SetLinearVelocity( GetPhysics()->GetLinearVelocity() );
physicsObj.SetLinearAcceleration( spawnArgs.GetFloat( "accel", "200" ) );
physicsObj.SetLinearDeceleration( spawnArgs.GetFloat( "decel", "200" ) );
viewAxis = idAngles( 0, spawnArgs.GetFloat( "angle" ) , 0 ).ToMat3();
physicsObj.SetAxis( GetPhysics()->GetAxis() * viewAxis );
physicsObj.SetOrigin( GetPhysics()->GetOrigin() );
SetPhysics( &physicsObj );
BecomeActive( TH_THINK );
accelWithStrafe = Sign( spawnArgs.GetFloat("accel_strafe") );
idealSpeed = spawnArgs.GetFloat( "speed", "200" );
PostEventMS( &EV_PostSpawn, 0 );
}
示例8: GetPhysics
/*
================
rvVehicleAnimated::Spawn
================
*/
void rvVehicleAnimated::Spawn( void ) {
turnRate = spawnArgs.GetFloat ( "turnRate", "90" );
viewAngles = GetPhysics()->GetAxis ( ).ToAngles ( );
viewAxis = viewAngles.ToMat3();
// Initialize the physics object
physicsObj.SetSelf( this );
physicsObj.SetClipModel( new idClipModel( GetPhysics()->GetClipModel() ), 1.0f );
physicsObj.SetContents( CONTENTS_BODY );
physicsObj.SetClipMask( MASK_PLAYERSOLID|CONTENTS_VEHICLECLIP );
physicsObj.SetMaxStepHeight( spawnArgs.GetFloat ( "stepheight", "14" ) );
// Start just a tad above the floor
physicsObj.SetOrigin( GetPhysics()->GetOrigin() + idVec3( 0, 0, CM_CLIP_EPSILON ) );
physicsObj.SetMass( spawnArgs.GetFloat( "mass", "100" ) );
physicsObj.SetDelta( vec3_origin );
// Gravity
idVec3 gravity = spawnArgs.GetVector( "gravityDir", "0 0 -1" );
gravity *= g_gravity.GetFloat ( );
physicsObj.SetGravity( gravity );
SetPhysics( &physicsObj );
animator.RemoveOriginOffset( true );
additionalDelta.Zero();
BecomeActive( TH_THINK );
}
示例9: BecomeActive
/*
================
idTarget_FadeEntity::Event_Activate
================
*/
void idTarget_FadeEntity::Event_Activate( idEntity *activator )
{
idEntity *ent;
int i;
if( !targets.Num() )
{
return;
}
// always allow during cinematics
cinematic = true;
BecomeActive( TH_THINK );
ent = this;
for( i = 0; i < targets.Num(); i++ )
{
ent = targets[ i ].GetEntity();
if( ent )
{
ent->GetColor( fadeFrom );
break;
}
}
fadeStart = gameLocal.time;
fadeEnd = gameLocal.time + SEC2MS( spawnArgs.GetFloat( "fadetime" ) );
}
示例10: BecomeActive
/*
================
idBrittleFracture::DropShard
================
*/
void idBrittleFracture::DropShard( shard_t* shard, const idVec3& point, const idVec3& dir, const float impulse, const int time )
{
int i, j, clipModelId;
float dist, f;
idVec3 dir2, origin;
idMat3 axis;
shard_t* neighbour;
// don't display decals on dropped shards
shard->decals.DeleteContents( true );
// remove neighbour pointers of neighbours pointing to this shard
for( i = 0; i < shard->neighbours.Num(); i++ )
{
neighbour = shard->neighbours[i];
for( j = 0; j < neighbour->neighbours.Num(); j++ )
{
if( neighbour->neighbours[j] == shard )
{
neighbour->neighbours.RemoveIndex( j );
break;
}
}
}
// remove neighbour pointers
shard->neighbours.Clear();
// remove the clip model from the static physics object
clipModelId = shard->clipModel->GetId();
physicsObj.SetClipModel( NULL, 1.0f, clipModelId, false );
origin = shard->clipModel->GetOrigin();
axis = shard->clipModel->GetAxis();
// set the dropped time for fading
shard->droppedTime = time;
dir2 = origin - point;
dist = dir2.Normalize();
f = dist > maxShatterRadius ? 1.0f : idMath::Sqrt( idMath::Fabs( dist - minShatterRadius ) ) * ( 1.0f / idMath::Sqrt( idMath::Fabs( maxShatterRadius - minShatterRadius ) ) );
// setup the physics
shard->physicsObj.SetSelf( this );
shard->physicsObj.SetClipModel( shard->clipModel, density );
shard->physicsObj.SetMass( shardMass );
shard->physicsObj.SetOrigin( origin );
shard->physicsObj.SetAxis( axis );
shard->physicsObj.SetBouncyness( bouncyness );
shard->physicsObj.SetFriction( 0.6f, 0.6f, friction );
shard->physicsObj.SetGravity( gameLocal.GetGravity() );
shard->physicsObj.SetContents( CONTENTS_RENDERMODEL );
shard->physicsObj.SetClipMask( MASK_SOLID | CONTENTS_MOVEABLECLIP );
shard->physicsObj.ApplyImpulse( 0, origin, impulse * linearVelocityScale * dir );
shard->physicsObj.SetAngularVelocity( dir.Cross( dir2 ) * ( f * angularVelocityScale ) );
shard->clipModel->SetId( clipModelId );
BecomeActive( TH_PHYSICS );
}
示例11: BecomeActive
/*
===============
tdmFuncShooter::Spawn
===============
*/
void tdmFuncShooter::Spawn() {
_active = !spawnArgs.GetBool( "start_off" );
_lastFireTime = 0;
_fireInterval = spawnArgs.GetInt( "fire_interval", "-1" );
_fireIntervalFuzzyness = spawnArgs.GetInt( "fire_interval_fuzzyness", "0" );
_startDelay = spawnArgs.GetInt( "start_delay", "0" );
idStr reqStimStr = spawnArgs.GetString( "required_stim" );
if( !reqStimStr.IsEmpty() ) {
_requiredStim = CStimResponse::GetStimType( reqStimStr );
_requiredStimTimeOut = spawnArgs.GetInt( "required_stim_timeout", "5000" );
}
_triggerRequired = spawnArgs.GetBool( "required_trigger" );
_triggerTimeOut = spawnArgs.GetInt( "required_trigger_timeout", "4000" );
_ammo = spawnArgs.GetInt( "ammo", "-1" );
_useAmmo = ( _ammo != -1 );
if( _active && _fireInterval > 0 ) {
BecomeActive( TH_THINK );
setupNextFireTime();
_nextFireTime += _startDelay;
// Set the end time if we have a positive lifetime
int maxLifeTime = spawnArgs.GetInt( "max_lifetime", "-1" );
if( maxLifeTime > 0 ) {
_endTime = gameLocal.time + SEC2MS( maxLifeTime );
}
}
// Always react to stims if a required stim is setup.
if( _requiredStim != ST_DEFAULT ) {
//DM_LOG(LC_STIM_RESPONSE, LT_INFO)LOGSTRING("tdmFuncShooter is requiring stim %d\r", _requiredStim);
GetPhysics()->SetContents( GetPhysics()->GetContents() | CONTENTS_RESPONSE );
}
}
示例12: memset
/*
================
idExplodingBarrel::AddParticles
================
*/
void idExplodingBarrel::AddParticles( const char *name, bool burn ) {
if ( name && *name ) {
if ( particleModelDefHandle >= 0 ){
gameRenderWorld->FreeEntityDef( particleModelDefHandle );
}
memset( &particleRenderEntity, 0, sizeof ( particleRenderEntity ) );
const idDeclModelDef *modelDef = static_cast<const idDeclModelDef *>( declManager->FindType( DECL_MODELDEF, name ) );
if ( modelDef ) {
particleRenderEntity.origin = physicsObj.GetAbsBounds().GetCenter();
particleRenderEntity.axis = mat3_identity;
particleRenderEntity.hModel = modelDef->ModelHandle();
float rgb = ( burn ) ? 0.0f : 1.0f;
particleRenderEntity.shaderParms[ SHADERPARM_RED ] = rgb;
particleRenderEntity.shaderParms[ SHADERPARM_GREEN ] = rgb;
particleRenderEntity.shaderParms[ SHADERPARM_BLUE ] = rgb;
particleRenderEntity.shaderParms[ SHADERPARM_ALPHA ] = rgb;
particleRenderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.realClientTime );
particleRenderEntity.shaderParms[ SHADERPARM_DIVERSITY ] = ( burn ) ? 1.0f : gameLocal.random.RandomInt( 90 );
particleRenderEntity.suppressSurfaceInViewID = -8; // sikk - Depth Render
if ( !particleRenderEntity.hModel ) {
particleRenderEntity.hModel = renderModelManager->FindModel( name );
}
particleModelDefHandle = gameRenderWorld->AddEntityDef( &particleRenderEntity );
if ( burn ) {
BecomeActive( TH_THINK );
}
particleTime = gameLocal.realClientTime;
}
}
}
示例13: at
/*
================
idSound::Spawn
================
*/
void idSound::Spawn( void ) {
spawnArgs.GetVector( "move", "0 0 0", shakeTranslate );
spawnArgs.GetAngles( "rotate", "0 0 0", shakeRotate );
spawnArgs.GetFloat( "random", "0", random );
spawnArgs.GetFloat( "wait", "0", wait );
if ( ( wait > 0.0f ) && ( random >= wait ) ) {
random = wait - 0.001;
gameLocal.Warning( "speaker '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString(0) );
}
soundVol = 0.0f;
lastSoundVol = 0.0f;
if ( ( shakeRotate != ang_zero ) || ( shakeTranslate != vec3_zero ) ) {
BecomeActive( TH_THINK );
}
if ( !refSound.waitfortrigger && ( wait > 0.0f ) ) {
timerOn = true;
PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random );
} else {
timerOn = false;
}
// add this speaker to the list of ambient music speakers affected by tdm_music_volume
if ( spawnArgs.GetBool( "s_music" ) ) {
gameLocal.musicSpeakers.Append( entityNumber );
}
}
示例14: Setup
/*
================
idEntityFx::Event_Trigger
================
*/
void idEntityFx::Event_Trigger( idEntity *activator ) {
if ( g_skipFX.GetBool() ) {
return;
}
float fxActionDelay;
const char *fx;
if ( gameLocal.time < nextTriggerTime ) {
return;
}
if ( spawnArgs.GetString( "fx", "", &fx) ) {
Setup( fx );
Start( gameLocal.time );
PostEventMS( &EV_Fx_KillFx, Duration() );
BecomeActive( TH_THINK );
}
fxActionDelay = spawnArgs.GetFloat( "fxActionDelay" );
if ( fxActionDelay != 0.0f ) {
nextTriggerTime = gameLocal.time + SEC2MS( fxActionDelay );
} else {
// prevent multiple triggers on same frame
nextTriggerTime = gameLocal.time + 1;
}
PostEventSec( &EV_Fx_Action, fxActionDelay, activator );
}
示例15: CheckSpawn
/*
==============
idSpawner::Event_Activate
==============
*/
void idSpawner::Event_Activate( idEntity *activator ) {
// "trigger_only" spawners will attempt to spawn when triggered
if ( spawnArgs.GetBool( "trigger_only" ) ) {
// Update next spawn time to follo CheckSpawn into thinking its time to spawn again
nextSpawnTime = gameLocal.time;
CheckSpawn();
return;
}
// If nextSpawnTime is zero then the spawner is currently deactivated
if ( nextSpawnTime == 0 ) {
// Start thinking
BecomeActive( TH_THINK );
// Allow immediate spawn
nextSpawnTime = gameLocal.time;
// Spawn any ai targets and add them to the current count
ActivateTargets( this );
} else {
nextSpawnTime = 0;
BecomeInactive( TH_THINK );
// Remove the spawner if need be
if ( spawnArgs.GetBool( "remove", "1" ) ) {
PostEventMS( &EV_Remove, 0 );
}
}
}