本文整理汇总了C++中VPhysicsGetObject函数的典型用法代码示例。如果您正苦于以下问题:C++ VPhysicsGetObject函数的具体用法?C++ VPhysicsGetObject怎么用?C++ VPhysicsGetObject使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VPhysicsGetObject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: max
void CNPC_HL1Barney::SUB_LVFadeOut( void )
{
if( VPhysicsGetObject() )
{
if( VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_PLAYER_HELD || GetEFlags() & EFL_IS_BEING_LIFTED_BY_BARNACLE )
{
// Try again in a few seconds.
SetNextThink( gpGlobals->curtime + 5 );
SetRenderColorA( 255 );
return;
}
}
float dt = gpGlobals->frametime;
if ( dt > 0.1f )
{
dt = 0.1f;
}
m_nRenderMode = kRenderTransTexture;
int speed = max(3,256*dt); // fade out over 3 seconds
SetRenderColorA( UTIL_Approach( 0, m_clrRender->a, speed ) );
NetworkStateChanged();
if ( m_clrRender->a == 0 )
{
UTIL_Remove(this);
}
else
{
SetNextThink( gpGlobals->curtime );
}
}
示例2: EmitSound
//---------------------------------------------------------
//---------------------------------------------------------
void CBounceBomb::CloseHooks()
{
if( !m_bLockSilently )
{
EmitSound( "NPC_CombineMine.CloseHooks" );
}
if( VPhysicsGetObject() )
{
// It's possible to not have a valid physics object here, since this function doubles as an initialization function.
PhysSetGameFlags( VPhysicsGetObject(), FVPHYSICS_CONSTRAINT_STATIC );
}
// Only lock silently the first time we call this.
m_bLockSilently = false;
SetPoseParameter( m_iAllHooks, 0 );
VPhysicsGetObject()->EnableMotion( false );
// Once I lock down, forget how many tries it took.
m_iFlipAttempts = 0;
#ifdef _XBOX
AddEffects( EF_NOSHADOW );
#endif
}
示例3: LaserOff
void CNPC_Portal_FloorTurret::InactiveThink( void )
{
LaserOff();
RopesOff();
// Update our PVS state
CheckPVSCondition();
SetNextThink( gpGlobals->curtime + 1.0f );
// Wake up if we're not on our side
if ( !OnSide() && VPhysicsGetObject()->GetContactPoint( NULL, NULL ) && m_bEnabled )
{
// Never return to life!
SetCollisionGroup( COLLISION_GROUP_NONE );
//ReturnToLife();
}
else
{
IPhysicsObject *pTurretPhys = VPhysicsGetObject();
if ( !(pTurretPhys->GetGameFlags() & FVPHYSICS_PLAYER_HELD) && pTurretPhys->IsAsleep() )
SetCollisionGroup( COLLISION_GROUP_DEBRIS_TRIGGER );
else
SetCollisionGroup( COLLISION_GROUP_NONE );
}
}
示例4: PhysModelParseSolid
bool CPhysBox::CreateVPhysics()
{
solid_t tmpSolid;
PhysModelParseSolid( tmpSolid, this, GetModelIndex() );
if ( m_massScale > 0 )
{
float mass = tmpSolid.params.mass * m_massScale;
mass = clamp( mass, 0.5, 1e6 );
tmpSolid.params.mass = mass;
}
PhysSolidOverride( tmpSolid, m_iszOverrideScript );
IPhysicsObject *pPhysics = VPhysicsInitNormal( GetSolid(), GetSolidFlags(), true, &tmpSolid );
if ( m_damageType == 1 )
{
PhysSetGameFlags( pPhysics, FVPHYSICS_DMG_SLICE );
}
// Wake it up if not asleep
if ( !HasSpawnFlags(SF_PHYSBOX_ASLEEP) )
{
VPhysicsGetObject()->Wake();
}
if ( HasSpawnFlags(SF_PHYSBOX_MOTIONDISABLED) || m_damageToEnableMotion > 0 )
{
VPhysicsGetObject()->EnableMotion( false );
}
// only send data when physics moves this object
NetworkStateManualMode( true );
return true;
}
示例5: GetAbsOrigin
bool CBounceBomb::IsValidLocation()
{
CBaseEntity *pAvoidObject = NULL;
float flAvoidForce = 0.0f;
CAI_Hint *pHint;
CHintCriteria criteria;
criteria.SetHintType( HINT_WORLD_INHIBIT_COMBINE_MINES );
criteria.SetFlag( bits_HINT_NODE_NEAREST );
criteria.AddIncludePosition( GetAbsOrigin(), 12.0f * 15.0f );
pHint = CAI_HintManager::FindHint( GetAbsOrigin(), criteria );
if( pHint )
{
pAvoidObject = pHint;
flAvoidForce = 120.0f;
}
else
{
// Look for other mines that are too close to me.
CBaseEntity *pEntity = gEntList.FirstEnt();
Vector vecMyPosition = GetAbsOrigin();
while( pEntity )
{
if( pEntity->m_iClassname == m_iClassname && pEntity != this )
{
// Don't lock down if I'm near a mine that's already locked down.
if( vecMyPosition.DistToSqr(pEntity->GetAbsOrigin()) < MINE_MIN_PROXIMITY_SQR )
{
pAvoidObject = pEntity;
flAvoidForce = 60.0f;
break;
}
}
pEntity = gEntList.NextEnt( pEntity );
}
}
if( pAvoidObject )
{
// Build a force vector to push us away from the inhibitor.
// Start by pushing upwards.
Vector vecForce = Vector( 0, 0, VPhysicsGetObject()->GetMass() * 200.0f );
// Now add some force in the direction that takes us away from the inhibitor.
Vector vecDir = GetAbsOrigin() - pAvoidObject->GetAbsOrigin();
vecDir.z = 0.0f;
VectorNormalize( vecDir );
vecForce += vecDir * VPhysicsGetObject()->GetMass() * flAvoidForce;
Flip( vecForce, AngularImpulse( 100, 0, 0 ) );
// Tell the code that asked that this position isn't valid.
return false;
}
return true;
}
示例6: VPhysicsGetObject
bool C_PhysPropClientside::IsAsleep()
{
if ( VPhysicsGetObject() )
{
return VPhysicsGetObject()->IsAsleep();
}
return true;
}
示例7: CalcLocalThrust
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPhysicsCannister::CannisterActivate( CBaseEntity *pActivator, const Vector &thrustOffset )
{
// already active or spent
if ( m_active || !m_thrustTime )
{
return;
}
m_hLauncher = pActivator;
Vector thrustDirection = CalcLocalThrust( thrustOffset );
m_onActivate.FireOutput( pActivator, this, 0 );
m_thruster.CalcThrust( m_thrustOrigin, thrustDirection, VPhysicsGetObject() );
m_pController = physenv->CreateMotionController( &m_thruster );
IPhysicsObject *pPhys = VPhysicsGetObject();
m_pController->AttachObject( pPhys, true );
// Make sure the object is simulated
pPhys->Wake();
m_active = true;
m_activateTime = gpGlobals->curtime;
SetNextThink( gpGlobals->curtime + m_thrustTime );
SetThink( &CPhysicsCannister::BeginShutdownThink );
QAngle angles;
VectorAngles( -thrustDirection, angles );
m_pJet = dynamic_cast<CSteamJet *>( CBaseEntity::Create( "env_steam", m_thrustOrigin, angles, this ) );
m_pJet->SetParent( this );
float extra = m_thruster.m_thrust * (1/5000.f);
extra = clamp( extra, 0, 1 );
m_pJet->m_SpreadSpeed = 15 * m_thruster.m_thrust * 0.001;
m_pJet->m_Speed = 128 + 100 * extra;
m_pJet->m_StartSize = 10;
m_pJet->m_EndSize = 25;
m_pJet->m_Rate = 52 + (int)extra*20;
m_pJet->m_JetLength = 64;
m_pJet->m_clrRender = m_clrRender;
m_pJet->Use( this, this, USE_ON, 1 );
if ( m_gasSound != NULL_STRING )
{
CPASAttenuationFilter filter( this );
EmitSound_t ep;
ep.m_nChannel = CHAN_ITEM;
ep.m_pSoundName = STRING(m_gasSound);
ep.m_flVolume = 1.0f;
ep.m_SoundLevel = SNDLVL_NORM;
EmitSound( filter, entindex(), ep );
}
}
示例8: Assert
//-----------------------------------------------------------------------------
// Purpose: If we are shot after being stuck to the world, move a bit
//-----------------------------------------------------------------------------
int CTFGrenadePipebombProjectile::OnTakeDamage( const CTakeDamageInfo &info )
{
if ( !info.GetAttacker() )
{
Assert( !info.GetAttacker() );
return 0;
}
bool bSameTeam = ( info.GetAttacker()->GetTeamNumber() == GetTeamNumber() );
if ( m_bTouched && ( info.GetDamageType() & (DMG_BULLET|DMG_BUCKSHOT|DMG_BLAST) ) && bSameTeam == false )
{
Vector vecForce = info.GetDamageForce();
if ( info.GetDamageType() & DMG_BULLET )
{
vecForce *= tf_grenade_forcefrom_bullet.GetFloat();
}
else if ( info.GetDamageType() & DMG_BUCKSHOT )
{
vecForce *= tf_grenade_forcefrom_buckshot.GetFloat();
}
else if ( info.GetDamageType() & DMG_BLAST )
{
vecForce *= tf_grenade_forcefrom_blast.GetFloat();
}
// If the force is sufficient, detach & move the pipebomb
float flForce = tf_pipebomb_force_to_move.GetFloat();
if ( vecForce.LengthSqr() > (flForce*flForce) )
{
if ( VPhysicsGetObject() )
{
VPhysicsGetObject()->EnableMotion( true );
}
CTakeDamageInfo newInfo = info;
newInfo.SetDamageForce( vecForce );
VPhysicsTakeDamage( newInfo );
// The pipebomb will re-stick to the ground after this time expires
m_flMinSleepTime = gpGlobals->curtime + tf_grenade_force_sleeptime.GetFloat();
m_bTouched = false;
// It has moved the data is no longer valid.
m_bUseImpactNormal = false;
m_vecImpactNormal.Init();
return 1;
}
}
return 0;
}
示例9: UpdateLight
//---------------------------------------------------------
//---------------------------------------------------------
void CBounceBomb::OnRestore()
{
BaseClass::OnRestore();
if ( gpGlobals->eLoadType == MapLoad_Transition && !m_hSprite && m_LastSpriteColor.GetRawColor() != 0 )
{
UpdateLight( true, m_LastSpriteColor.r(), m_LastSpriteColor.g(), m_LastSpriteColor.b(), m_LastSpriteColor.a() );
}
if( VPhysicsGetObject() )
{
VPhysicsGetObject()->Wake();
}
}
示例10: SetSolid
void C_BasePropDoor::OnDataChanged( DataUpdateType_t type )
{
BaseClass::OnDataChanged( type );
if ( type == DATA_UPDATE_CREATED )
{
SetSolid(SOLID_VPHYSICS);
VPhysicsInitShadow( false, false );
}
else if ( VPhysicsGetObject() )
{
VPhysicsGetObject()->UpdateShadow( GetAbsOrigin(), GetAbsAngles(), false, TICK_INTERVAL );
}
}
示例11: SetThink
//---------------------------------------------------------
// Bouncbomb flips to try to right itself, try to get off
// of and object that it's not allowed to clamp to, or
// to get away from a hint node that inhibits placement
// of mines.
//---------------------------------------------------------
void CBounceBomb::Flip( const Vector &vecForce, const AngularImpulse &torque )
{
if( m_iFlipAttempts > BOUNCEBOMB_MAX_FLIPS )
{
// Not allowed to try anymore.
SetThink(NULL);
return;
}
EmitSound( "NPC_CombineMine.FlipOver" );
VPhysicsGetObject()->ApplyForceCenter( vecForce );
VPhysicsGetObject()->ApplyTorqueCenter( torque );
m_iFlipAttempts++;
}
示例12: VPhysicsGetObject
bool CNPC_Crow::BecomeRagdollOnClient( const Vector &force )
{
Vector newForce = force;
if( VPhysicsGetObject() )
{
float flMass = VPhysicsGetObject()->GetMass();
float speed = VectorNormalize( newForce );
speed = min( speed, (CROW_RAGDOLL_SPEED_LIMIT * flMass) );
newForce *= speed;
}
return BaseClass::BecomeRagdollOnClient( newForce );
}
示例13: VPhysicsGetObject
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectSiegePlatform::SetObjectCollisionBox( void )
{
if ( VPhysicsGetObject() )
{
Vector absmins, absmaxs;
physcollision->CollideGetAABB( absmins, absmaxs, VPhysicsGetObject()->GetCollide(), GetAbsOrigin(), GetAbsAngles() );
SetAbsMins( absmins );
SetAbsMaxs( absmaxs );
return;
}
else
{
BaseClass::SetObjectCollisionBox();
}
}
示例14: VPhysicsGetObject
void C_HL2MPRagdoll::ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName )
{
IPhysicsObject *pPhysicsObject = VPhysicsGetObject();
if( !pPhysicsObject )
return;
Vector dir = pTrace->endpos - pTrace->startpos;
if ( iDamageType == DMG_BLAST )
{
dir *= 4000; // adjust impact strenght
// apply force at object mass center
pPhysicsObject->ApplyForceCenter( dir );
}
else
{
Vector hitpos;
VectorMA( pTrace->startpos, pTrace->fraction, dir, hitpos );
VectorNormalize( dir );
dir *= 4000; // adjust impact strenght
// apply force where we hit it
pPhysicsObject->ApplyForceOffset( dir, hitpos );
// Blood spray!
// FX_CS_BloodSpray( hitpos, dir, 10 );
}
m_pRagdoll->ResetRagdollSleepAfterTime();
}
示例15: Precache
void CPhysicsCannister::Spawn( void )
{
Precache();
SetModel( STRING(GetModelName()) );
SetBloodColor( DONT_BLEED );
AddSolidFlags( FSOLID_CUSTOMRAYTEST );
m_takedamage = DAMAGE_YES;
SetNextThink( TICK_NEVER_THINK );
if ( m_iHealth <= 0 )
m_iHealth = 25;
m_flAnimTime = gpGlobals->curtime;
m_flPlaybackRate = 0.0;
SetCycle( 0 );
m_bFired = false;
// not thrusting
m_active = false;
CreateVPhysics();
if ( !VPhysicsGetObject() )
{
// must have a physics object or code will crash later
UTIL_Remove(this);
}
}