本文整理汇总了C++中IPhysicsObject::EnableMotion方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicsObject::EnableMotion方法的具体用法?C++ IPhysicsObject::EnableMotion怎么用?C++ IPhysicsObject::EnableMotion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicsObject
的用法示例。
在下文中一共展示了IPhysicsObject::EnableMotion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTakeDamage
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CPhysBox::OnTakeDamage( const CTakeDamageInfo &info )
{
// note: if motion is disabled, OnTakeDamage can't apply physics force
int ret = BaseClass::OnTakeDamage( info );
// Check our health against the threshold:
if( m_damageToEnableMotion > 0 && GetHealth() < m_damageToEnableMotion )
{
// only do this once
m_damageToEnableMotion = 0;
IPhysicsObject *pPhysicsObject = VPhysicsGetObject();
if ( pPhysicsObject != NULL )
{
pPhysicsObject->Wake();
pPhysicsObject->EnableMotion( true );
VPhysicsTakeDamage( info );
}
}
if ( info.GetInflictor() )
{
m_OnDamaged.FireOutput( info.GetAttacker(), this );
}
return ret;
}
示例2: Event_Killed
void CStatueProp::Event_Killed( const CTakeDamageInfo &info )
{
IPhysicsObject *pPhysics = VPhysicsGetObject();
if ( pPhysics && !pPhysics->IsMoveable() )
{
pPhysics->EnableMotion( true );
VPhysicsTakeDamage( info );
}
m_nShatterFlags = 0; // If you have some flags to network for the shatter effect, put them here!
m_vShatterPosition = info.GetDamagePosition();
m_vShatterForce = info.GetDamageForce();
m_bShatter = true;
// Skip over breaking code!
//Break( info.GetInflictor(), info );
//BaseClass::Event_Killed( info );
// FIXME: Short delay before we actually remove so that the client statue gets a network update before we need it
// This isn't a reliable way to do this and needs to be rethought.
AddSolidFlags( FSOLID_NOT_SOLID );
SetNextThink( gpGlobals->curtime + 0.2f );
SetThink( &CBaseEntity::SUB_Remove );
}
示例3: Spawn
// as CItem, but we don't install the touch function
void CASW_Pickup::Spawn( void )
{
SetMoveType( MOVETYPE_FLYGRAVITY );
SetSolid( SOLID_BBOX );
SetBlocksLOS( false );
AddEFlags( EFL_NO_ROTORWASH_PUSH );
// This will make them not collide with the player, but will collide
// against other items + weapons
SetCollisionGroup( COLLISION_GROUP_WEAPON );
CollisionProp()->UseTriggerBounds( true, ITEM_PICKUP_BOX_BLOAT );
//SetTouch(&CItem::ItemTouch);
if ( CreateItemVPhysicsObject() == false )
return;
m_takedamage = DAMAGE_EVENTS_ONLY;
#ifdef HL2MP
SetThink( &CItem::FallThink );
SetNextThink( gpGlobals->curtime + 0.1f );
#endif
if ( m_bFreezePickup )
{
IPhysicsObject *pPhysicsObject = VPhysicsGetObject();
if ( pPhysicsObject != NULL )
{
pPhysicsObject->EnableMotion( false );
}
}
}
示例4: InputDisableMotion
//-----------------------------------------------------------------------------
// Purpose: Disable any physics motion or collision response
//-----------------------------------------------------------------------------
void CPhysBox::InputDisableMotion( inputdata_t &inputdata )
{
IPhysicsObject *pPhysicsObject = VPhysicsGetObject();
if ( pPhysicsObject != NULL )
{
pPhysicsObject->EnableMotion( false );
}
}
示例5: GetAbsVelocity
//------------------------------------------------------------------------------
// Pow!
//------------------------------------------------------------------------------
void CPropAPC2::ExplodeAndThrowChunk( const Vector &vecExplosionPos )
{
ExplosionCreate( vecExplosionPos, vec3_angle, this, 1000, 500.0f,
SF_ENVEXPLOSION_NODAMAGE | SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS |
SF_ENVEXPLOSION_NOSMOKE | SF_ENVEXPLOSION_NOFIREBALLSMOKE, 0 );
UTIL_ScreenShake( vecExplosionPos, 25.0, 150.0, 1.0, 750.0f, SHAKE_START );
// Drop a flaming, smoking chunk.
CGib *pChunk = CREATE_ENTITY( CGib, "gib" );
pChunk->Spawn( "models/gibs/hgibs.mdl" );
pChunk->SetBloodColor( DONT_BLEED );
QAngle vecSpawnAngles;
vecSpawnAngles.Random( -90, 90 );
pChunk->SetAbsOrigin( vecExplosionPos );
pChunk->SetAbsAngles( vecSpawnAngles );
int nGib = random->RandomInt( 0, APC_MAX_CHUNKS - 1 );
pChunk->Spawn( s_pChunkModelName[nGib] );
pChunk->SetOwnerEntity( this );
pChunk->m_lifeTime = random->RandomFloat( 6.0f, 8.0f );
pChunk->SetCollisionGroup( COLLISION_GROUP_DEBRIS );
IPhysicsObject *pPhysicsObject = pChunk->VPhysicsInitNormal( SOLID_VPHYSICS, pChunk->GetSolidFlags(), false );
// Set the velocity
if ( pPhysicsObject )
{
pPhysicsObject->EnableMotion( true );
Vector vecVelocity;
QAngle angles;
angles.x = random->RandomFloat( -40, 0 );
angles.y = random->RandomFloat( 0, 360 );
angles.z = 0.0f;
AngleVectors( angles, &vecVelocity );
vecVelocity *= random->RandomFloat( 300, 900 );
vecVelocity += GetAbsVelocity();
AngularImpulse angImpulse;
angImpulse = RandomAngularImpulse( -180, 180 );
pChunk->SetAbsVelocity( vecVelocity );
pPhysicsObject->SetVelocity(&vecVelocity, &angImpulse );
}
CEntityFlame *pFlame = CEntityFlame::Create( pChunk, false );
if ( pFlame != NULL )
{
pFlame->SetLifetime( pChunk->m_lifeTime );
}
pChunk->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
}
示例6: Event_Killed
void CASW_Barrel_Explosive::Event_Killed( const CTakeDamageInfo &info )
{
IPhysicsObject *pPhysics = VPhysicsGetObject();
if ( pPhysics && !pPhysics->IsMoveable() )
{
pPhysics->EnableMotion( true );
VPhysicsTakeDamage( info );
}
QueueForExplode( info );
// Break( info.GetInflictor(), info );
// DoExplosion();
}
示例7:
void CWeaponSF132Cannon::FreezeHeldBlock( void )
{
#ifndef CLIENT_DLL
CBaseEntity *pEntity = m_grabController.GetAttached();
if ( pEntity )
{
IPhysicsObject *pPhysicsObject = pEntity->VPhysicsGetObject();
if ( pPhysicsObject != NULL )
{
pPhysicsObject->EnableMotion( false );
}
}
#endif // CLIENT_DLL
}
示例8: Spawn
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectSiegePlatform::Spawn()
{
Precache();
SetModel( SIEGE_TOWER_PLATFORM_MODEL );
SetSolid( SOLID_VPHYSICS );
m_takedamage = DAMAGE_NO;
BaseClass::Spawn();
IPhysicsObject *pPhysics = VPhysicsInitStatic();
if ( pPhysics )
{
pPhysics->EnableMotion( false );
}
SetCollisionGroup( TFCOLLISION_GROUP_OBJECT_SOLIDTOPLAYERMOVEMENT );
}
示例9: Spawn
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectTowerLadder::Spawn()
{
Precache();
SetModel( TOWER_LADDER_MODEL );
SetSolid( SOLID_VPHYSICS );
m_takedamage = DAMAGE_NO;
BaseClass::Spawn();
IPhysicsObject *pPhysics = VPhysicsInitStatic();
if ( pPhysics )
{
pPhysics->EnableMotion( false );
}
SetCollisionGroup( COLLISION_GROUP_VEHICLE );
}
示例10: Spawn
void CTripmineGrenade::Spawn( void )
{
Precache( );
// motor
SetMoveType( MOVETYPE_FLY );
SetSolid( SOLID_BBOX );
SetModel( "models/Weapons/w_slam.mdl" );
IPhysicsObject *pObject = VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, true );
pObject->EnableMotion( false );
SetCollisionGroup( COLLISION_GROUP_WEAPON );
SetCycle( 0.0f );
m_nBody = 3;
m_flDamage = sk_plr_dmg_tripmine.GetFloat();
m_DmgRadius = sk_tripmine_radius.GetFloat();
ResetSequenceInfo( );
m_flPlaybackRate = 0;
UTIL_SetSize(this, Vector( -4, -4, -2), Vector(4, 4, 2));
m_flPowerUp = gpGlobals->curtime + 2.0;
SetThink( &CTripmineGrenade::PowerupThink );
SetNextThink( gpGlobals->curtime + 0.2 );
m_takedamage = DAMAGE_YES;
m_iHealth = 1;
EmitSound( "TripmineGrenade.Place" );
SetDamage ( 200 );
// Tripmine sits at 90 on wall so rotate back to get m_vecDir
QAngle angles = GetAbsAngles();
angles.x -= 90;
AngleVectors( angles, &m_vecDir );
m_vecEnd = GetAbsOrigin() + m_vecDir * 2048;
AddEffects( EF_NOSHADOW );
}
示例11: TransferPhysicsObject
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTriggerPortalCleanser::TransferPhysicsObject( CBaseEntity *pFrom, CBaseEntity *pTo, bool wakeUp )
{
IPhysicsObject *pVPhysics = pFrom->VPhysicsGetObject();
if ( !pVPhysics || pVPhysics->IsStatic() )
return false;
Vector vecVelocity, vecAngular;
pVPhysics->GetVelocity( &vecVelocity, &vecAngular );
// clear out the pointer so it won't get deleted
pFrom->VPhysicsSwapObject( NULL );
// remove any AI behavior bound to it
pVPhysics->RemoveShadowController();
// transfer to the new owner
pTo->VPhysicsSetObject( pVPhysics );
pVPhysics->SetGameData( (void *)pTo );
pTo->VPhysicsUpdate( pVPhysics );
// may have been temporarily disabled by the old object
pVPhysics->EnableMotion( true );
pVPhysics->EnableGravity( false );
// Slow down and push up the object.
vecVelocity /= 2;
vecAngular /= 2;
vecVelocity.z += 10;
pVPhysics->SetVelocity( &vecVelocity, &vecAngular );
// Update for the new entity solid type
pVPhysics->RecheckCollisionFilter();
if ( wakeUp )
{
pVPhysics->Wake();
}
return true;
}
示例12: TransferPhysicsObject
// UNDONE: Is this worth it?, just recreate the object instead? (that happens when this returns false anyway)
// recreating works, but is more expensive and won't inherit properties (velocity, constraints, etc)
bool TransferPhysicsObject( CBaseEntity *pFrom, CBaseEntity *pTo )
{
IPhysicsObject *pVPhysics = pFrom->VPhysicsGetObject();
if ( !pVPhysics || pVPhysics->IsStatic() )
return false;
// clear out the pointer so it won't get deleted
pFrom->VPhysicsSwapObject( NULL );
// remove any AI behavior bound to it
pVPhysics->RemoveShadowController();
// transfer to the new owner
pTo->VPhysicsSetObject( pVPhysics );
pVPhysics->SetGameData( (void *)pTo );
pTo->VPhysicsUpdate( pVPhysics );
// may have been temporarily disabled by the old object
pVPhysics->EnableMotion( true );
pVPhysics->EnableGravity( true );
// Update for the new entity solid type
pVPhysics->RecheckCollisionFilter();
return true;
}
示例13: Event_Killed
void CGEPropDynamic::Event_Killed(const CTakeDamageInfo &info)
{
// More or less just the kill event copied straight from prop_physics_respawnable, though it does not teleport as it cannot move on its own.
IPhysicsObject *pPhysics = VPhysicsGetObject();
if (pPhysics && !pPhysics->IsMoveable())
{
pPhysics->EnableMotion(true);
VPhysicsTakeDamage(info);
}
Break(info.GetInflictor(), info);
PhysCleanupFrictionSounds(this);
VPhysicsDestroyObject();
CBaseEntity::PhysicsRemoveTouchedList(this);
CBaseEntity::PhysicsRemoveGroundList(this);
DestroyAllDataObjects();
AddEffects(EF_NODRAW);
if (IsOnFire() || IsDissolving())
{
UTIL_Remove(GetEffectEntity());
}
SetContextThink(NULL, 0, "PROP_CLEARFLAGS");
if (m_flRespawnTime > 0)
{
SetThink(&CGEPropDynamic::Materialize);
SetNextThink(gpGlobals->curtime + m_flRespawnTime);
}
}
示例14: OnTouch
//.........这里部分代码省略.........
if ( pBAnim )
pBAnim->Ignite( 10.0f, false );
}
#endif
}
else
CalculateBulletDamageForce( &dmgInfo, m_iAmmoType, vecDir, touchtr.endpos, 1.0f );
dmgInfo.SetDamagePosition( touchtr.endpos );
ent->DispatchTraceAttack( dmgInfo, vecDir, &touchtr );
ApplyMultiDamage();
}
#ifdef CLIENT_DLL
if ( ent->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS )
return false;
//Decals and such
if ( !( touchtr.surface.flags & SURF_SKY ) && !touchtr.allsolid )
{
IPredictionSystem::SuppressEvents( false );
if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) )
{
UTIL_ImpactTrace( &touchtr, DMG_BULLET );
}
if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )
PlayImpactSound( touchtr.m_pEnt, touchtr, touchtr.endpos, touchtr.surface.surfaceProps );
IPredictionSystem::SuppressEvents( !prediction->IsFirstTimePredicted() );
}
#endif
}
if ( pTraceFilter && m_iType != DHL_PROJECTILE_TYPE_COMBATKNIFE )
{
PenetrationData_t nPenetrationData = DHLShared::TestPenetration( touchtr, m_pShooter, pTraceFilter,
m_iTimesPenetrated, m_flDistanceTravelled, m_iAmmoType );
if ( nPenetrationData.m_bShouldPenetrate )
{
m_flDistanceTravelled += GetLocalOrigin().DistTo( nPenetrationData.m_vecNewBulletPos );
MoveProjectileToPosition( nPenetrationData.m_vecNewBulletPos );
m_iTimesPenetrated++;
return true; //Keep going - but don't do anything else in this frame of PhysicsSimulate()
}
}
//We're done unless what we hit was breakable glass
if ( ent->GetCollisionGroup() != COLLISION_GROUP_BREAKABLE_GLASS )
{
#ifdef CLIENT_DLL
m_bCollided = true;
AddEffects( EF_NODRAW );
if ( m_pTrail ) //NULL pointer here sometimes somehow...
m_pTrail->AddEffects( EF_NODRAW );
#else
EntityMessageBegin( this );
WRITE_BYTE( MSG_NOTIFY_REMOVAL );
MessageEnd();
if ( touchtr.DidHitWorld() && m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE && !( touchtr.surface.flags & SURF_SKY ) )
{
CBaseCombatWeapon* pKnifeEnt = assert_cast<CBaseCombatWeapon*>(CreateEntityByName( "weapon_combatknife" ));
if ( pKnifeEnt )
{
pKnifeEnt->AddSpawnFlags( SF_NORESPAWN ); //Needed for weapon spawn & VPhysics setup to work correctly
pKnifeEnt->SetAbsOrigin( touchtr.endpos );
QAngle angles = vec3_angle;
Vector vecKnifeDir = touchtr.startpos - touchtr.endpos;
VectorAngles( vecKnifeDir, angles );
angles[PITCH] -= 15.0f; //Correct for the .mdl being offset a bit
pKnifeEnt->SetLocalAngles( angles );
DispatchSpawn( pKnifeEnt );
//Spawns vphys object and sets it up, essentially a copy of CWeaponHL2MPBase::FallInit()
pKnifeEnt->VPhysicsDestroyObject();
//Using SOLID_VPHYSICS instead of SOLID_BBOX (as ordinary weapons do) helps resolve some of the client side collision oddities
Assert( pKnifeEnt->VPhysicsInitNormal( SOLID_VPHYSICS, FSOLID_NOT_STANDABLE | FSOLID_TRIGGER, true ) );
pKnifeEnt->SetPickupTouch(); //Sets up automagic removal after time
IPhysicsObject* pKnifePhys = pKnifeEnt->VPhysicsGetObject();
if ( pKnifePhys )
{
//Knives are solid to bullets...the only way to make them non-solid to bullets is to do SetSolid( SOLID_NONE ) or AddSolidFlags( FSOLID_NOT_SOLID )
//which breaks the +use pickup even with FSOLID_TRIGGER set. Let's just call it a feature :)
pKnifePhys->EnableMotion( false );
pKnifePhys->EnableCollisions( false );
}
if ( IsOnFire() )
pKnifeEnt->Ignite( 10.0f, false );
}
}
//SetThink( &CDHLProjectile::SUB_Remove );
//SetNextThink( gpGlobals->curtime + 0.1 );
//SUB_Remove();
//SetMoveType( MOVETYPE_NONE );
m_flRemoveAt = gpGlobals->curtime + 0.1f; //Give the notification message a head start so that the client will have time to react
#endif
}
}
return true;
}
示例15: PropBreakableCreateAll
//.........这里部分代码省略.........
if ( GetGibManager() )
{
GetGibManager()->AddGibToLRU( pBreakable->GetBaseAnimating() );
}
#endif
if ( pOwnerEntity && pOwnerEntity->IsEffectActive( EF_NOSHADOW ) )
{
pBreakable->AddEffects( EF_NOSHADOW );
}
// If burst scale is set, this piece should 'burst' away from
// the origin in addition to travelling in the wished velocity.
if ( list[i].burstScale != 0.0 )
{
Vector vecBurstDir = position - params.origin;
// If $autocenter wasn't used, try the center of the piece
if ( vecBurstDir == vec3_origin )
{
vecBurstDir = pBreakable->WorldSpaceCenter() - params.origin;
}
VectorNormalize( vecBurstDir );
pBreakable->ApplyAbsVelocityImpulse( vecBurstDir * list[i].burstScale );
}
// If this piece is supposed to be motion disabled, disable it
if ( list[i].isMotionDisabled )
{
IPhysicsObject *pPhysicsObject = pBreakable->VPhysicsGetObject();
if ( pPhysicsObject != NULL )
{
pPhysicsObject->EnableMotion( false );
}
}
}
}
}
// Then see if the propdata specifies any breakable pieces
else if ( pEntity )
{
IBreakableWithPropData *pBreakableInterface = dynamic_cast<IBreakableWithPropData*>(pEntity);
if ( pBreakableInterface && pBreakableInterface->GetBreakableModel() != NULL_STRING && pBreakableInterface->GetBreakableCount() )
{
breakmodel_t breakModel;
for ( int i = 0; i < pBreakableInterface->GetBreakableCount(); i++ )
{
if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) )
break;
Q_strncpy( breakModel.modelName, g_PropDataSystem.GetRandomChunkModel(STRING(pBreakableInterface->GetBreakableModel()), pBreakableInterface->GetMaxBreakableSize()), sizeof(breakModel.modelName) );
breakModel.health = 1;
breakModel.fadeTime = RandomFloat(5,10);
breakModel.fadeMinDist = 0.0f;
breakModel.fadeMaxDist = 0.0f;
breakModel.burstScale = params.defBurstScale;
breakModel.collisionGroup = COLLISION_GROUP_DEBRIS;
breakModel.isRagdoll = false;
breakModel.isMotionDisabled = false;
breakModel.placementName[0] = 0;
breakModel.placementIsBone = false;
Vector vecObbSize = pEntity->CollisionProp()->OBBSize();