本文整理汇总了C++中EHANDLE::WorldSpaceCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ EHANDLE::WorldSpaceCenter方法的具体用法?C++ EHANDLE::WorldSpaceCenter怎么用?C++ EHANDLE::WorldSpaceCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EHANDLE
的用法示例。
在下文中一共展示了EHANDLE::WorldSpaceCenter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdatePickupNavigation
//------------------------------------------------------------------------------
// Purpose : Fly towards our pickup target
//------------------------------------------------------------------------------
void CNPC_CombineDropship::UpdatePickupNavigation( void )
{
Vector vecPickup = m_hPickupTarget->WorldSpaceCenter();
SetDesiredPosition( vecPickup );
//NDebugOverlay::Cross3D( GetDesiredPosition(), -Vector(32,32,32), Vector(32,32,32), 0, 255, 255, true, 0.1f );
}
示例2: UpdateViewThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPointCommentaryNode::UpdateViewThink( void )
{
if ( !m_bActive )
return;
CBasePlayer *pPlayer = GetCommentaryPlayer();
if ( !pPlayer )
return;
// Swing the view towards the target
if ( m_hViewTarget )
{
QAngle angGoal;
QAngle angCurrent;
if ( m_hViewPositionMover )
{
angCurrent = m_hViewPositionMover->GetAbsAngles();
VectorAngles( m_hViewTarget->WorldSpaceCenter() - m_hViewPositionMover->GetAbsOrigin(), angGoal );
}
else
{
angCurrent = pPlayer->EyeAngles();
VectorAngles( m_hViewTarget->WorldSpaceCenter() - pPlayer->EyePosition(), angGoal );
}
// Accelerate towards the target goal angles
float dx = AngleDiff( angGoal.x, angCurrent.x );
float dy = AngleDiff( angGoal.y, angCurrent.y );
float mod = 1.0 - ExponentialDecay( 0.5, 0.3, gpGlobals->frametime );
float dxmod = dx * mod;
float dymod = dy * mod;
angCurrent.x = AngleNormalize( angCurrent.x + dxmod );
angCurrent.y = AngleNormalize( angCurrent.y + dymod );
if ( m_hViewPositionMover )
{
m_hViewPositionMover->SetAbsAngles( angCurrent );
}
else
{
pPlayer->SnapEyeAngles( angCurrent );
}
SetNextThink( gpGlobals->curtime, s_pCommentaryUpdateViewThink );
}
if ( m_hViewPosition.Get() )
{
if ( pPlayer->GetActiveWeapon() )
{
pPlayer->GetActiveWeapon()->Holster();
}
if ( !m_hViewPositionMover )
{
// Make an invisible info target entity for us to attach the view to,
// and move it to the desired view position.
m_hViewPositionMover = CreateEntityByName( "env_laserdot" );
m_hViewPositionMover->SetAbsAngles( pPlayer->EyeAngles() );
pPlayer->SetViewEntity( m_hViewPositionMover );
}
// Blend to the target position over time.
float flCurTime = (gpGlobals->curtime - m_flStartTime);
float flBlendPerc = clamp( flCurTime / 2.0, 0, 1 );
// Figure out the current view position
Vector vecCurEye;
VectorLerp( pPlayer->EyePosition(), m_hViewPosition.Get()->GetAbsOrigin(), flBlendPerc, vecCurEye );
m_hViewPositionMover->SetAbsOrigin( vecCurEye );
SetNextThink( gpGlobals->curtime, s_pCommentaryUpdateViewThink );
}
}
示例3: ThrowObject
//.........这里部分代码省略.........
pPhysObj->Wake();
if ( pPhysObj->GetShadowController() )
{
m_hPhysicsEnt->SetParent( NULL );
m_hPhysicsEnt->SetMoveType( (MoveType_t)m_iContainerMoveType );
m_hPhysicsEnt->SetOwnerEntity( this );
pPhysObj->RemoveShadowController();
pPhysObj->SetPosition( m_hPhysicsEnt->GetLocalOrigin(), m_hPhysicsEnt->GetLocalAngles(), true );
pPhysObj->RecheckCollisionFilter();
pPhysObj->RecheckContactPoints();
}
if ( m_hThrowTarget == NULL )
#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
m_hThrowTarget = UTIL_GetNearestVisiblePlayer(this);
#else
m_hThrowTarget = AI_GetSinglePlayer();
#endif //SecobMod__Enable_Fixed_Multiplayer_AI
Vector vThrowDirection;
if ( m_hThrowTarget )
{
Vector vThrowOrigin = m_hThrowTarget->GetAbsOrigin();
if ( m_hThrowTarget->IsPlayer() )
vThrowOrigin = vThrowOrigin + Vector( random->RandomFloat( -128, 128 ), random->RandomFloat( -128, 128 ), 0 );
Vector vecToss = VecCheckToss( this, vGunPos, vThrowOrigin, m_flThrowArcModifier, 1.0f, true );
if( vecToss == vec3_origin )
{
// Fix up an impossible throw so dog will at least toss the box in the target's general direction instead of dropping it.
// Also toss it up in the air so it will fall down and break. (Just throw the box up at a 45 degree angle)
Vector forward, up;
GetVectors( &forward, NULL, &up );
vecToss = forward + up;
VectorNormalize( vecToss );
vecToss *= pPhysObj->GetMass() * 30.0f;
}
vThrowDirection = vecToss + ( m_hThrowTarget->GetSmoothedVelocity() / 2 );
Vector vLinearDrag;
Vector unitVel = vThrowDirection;
VectorNormalize( unitVel );
float flTest = 1000 / vThrowDirection.Length();
float flDrag = pPhysObj->CalculateLinearDrag( vThrowDirection );
vThrowDirection = vThrowDirection + ( unitVel * ( flDrag * flDrag ) ) / flTest;
pPhysObj->SetVelocity( &vThrowDirection, &angVelocity );
m_flTimeToCatch = gpGlobals->curtime + dog_max_wait_time.GetFloat();
//Don't start pulling until the object is away from me.
//We base the time on the throw velocity.
m_flTimeToPull = gpGlobals->curtime + ( 1000 / vThrowDirection.Length() );
}
//Fire Output!
m_OnThrow.FireOutput( this, this );
ClearBeams();
if ( m_bBeamEffects == true )
{
EmitSound( "Weapon_PhysCannon.Launch" );
CBeam *pBeam = CBeam::BeamCreate( "sprites/orangelight1.vmt", 1.8 );
if ( pBeam != NULL )
{
pBeam->PointEntInit( m_hPhysicsEnt->WorldSpaceCenter(), this );
pBeam->SetEndAttachment( m_iPhysGunAttachment );
pBeam->SetWidth( 6.4 );
pBeam->SetEndWidth( 12.8 );
pBeam->SetBrightness( 255 );
pBeam->SetColor( 255, 255, 255 );
pBeam->LiveForTime( 0.2f );
pBeam->RelinkBeam();
pBeam->SetNoise( 2 );
}
Vector shotDir = ( m_hPhysicsEnt->WorldSpaceCenter() - vGunPos );
VectorNormalize( shotDir );
CPVSFilter filter( m_hPhysicsEnt->WorldSpaceCenter() );
te->GaussExplosion( filter, 0.0f, m_hPhysicsEnt->WorldSpaceCenter() - ( shotDir * 4.0f ), RandomVector(-1.0f, 1.0f), 0 );
}
}
}
}
示例4: PullObject
void CNPC_Dog::PullObject( bool bMantain )
{
if ( m_hPhysicsEnt == NULL )
{
TaskFail( "Ack! No Phys Object!");
return;
}
IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();
if ( pPhysObj == NULL )
{
TaskFail( "Pulling object with no Phys Object?!" );
return;
}
if( pPhysObj->GetGameFlags() & FVPHYSICS_PLAYER_HELD )
{
m_bHasObject = false;
ClearBeams();
TaskFail("Player Grabbed Ball");
return;
}
CreateBeams();
Vector vGunPos;
GetAttachment( m_iPhysGunAttachment, vGunPos );
float flDistance = ( vGunPos - m_hPhysicsEnt->WorldSpaceCenter() ).Length();
if ( bMantain == false )
{
if ( flDistance <= DOG_CATCH_DISTANCE )
{
m_hPhysicsEnt->SetOwnerEntity( this );
GetNavigator()->StopMoving();
//Fire Output!
m_OnPickup.FireOutput( this, this );
m_bHasObject = true;
ClearBeams();
TaskComplete();
return;
}
}
Vector vDir = ( vGunPos - m_hPhysicsEnt->WorldSpaceCenter() );
Vector vCurrentVel;
float flCurrentVel;
AngularImpulse vCurrentAI;
pPhysObj->GetVelocity( &vCurrentVel, &vCurrentAI );
flCurrentVel = vCurrentVel.Length();
VectorNormalize( vCurrentVel );
VectorNormalize( vDir );
float flVelMod = DOG_PULL_VELOCITY_MOD;
if ( bMantain == true )
flVelMod *= 2;
vCurrentVel = vCurrentVel * flCurrentVel * flVelMod;
vCurrentAI = vCurrentAI * DOG_PULL_ANGULARIMP_MOD;
pPhysObj->SetVelocity( &vCurrentVel, &vCurrentAI );
vDir = vDir * flDistance * (DOG_PULL_TO_GUN_VEL_MOD * 2);
Vector vAngle( 0, 0, 0 );
pPhysObj->AddVelocity( &vDir, &vAngle );
}
示例5: StartTask
//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_Dog::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_DOG_SETUP_THROW_TARGET:
{
SetupThrowTarget();
TaskComplete();
}
break;
case TASK_DOG_GET_PATH_TO_PHYSOBJ:
{
FindPhysicsObject( STRING( m_sObjectName ) );
if ( m_hPhysicsEnt == NULL )
{
FindPhysicsObject( NULL );
return;
}
IPhysicsObject *pPhysicsObject = m_hPhysicsEnt->VPhysicsGetObject();
Vector vecGoalPos;
Vector vecDir;
vecDir = GetLocalOrigin() - m_hPhysicsEnt->WorldSpaceCenter();
VectorNormalize(vecDir);
vecDir.z = 0;
if ( m_hPhysicsEnt->GetOwnerEntity() == NULL )
m_hPhysicsEnt->SetOwnerEntity( this );
if ( pPhysicsObject )
pPhysicsObject->RecheckCollisionFilter();
vecGoalPos = m_hPhysicsEnt->WorldSpaceCenter() + (vecDir * DOG_PHYSOBJ_MOVE_TO_DIST );
//If I'm near my goal, then just walk to it.
Activity aActivity = ACT_RUN;
if ( ( vecGoalPos - GetLocalOrigin() ).Length() <= 128 )
aActivity = ACT_WALK;
if ( GetNavigator()->SetGoal( AI_NavGoal_t( vecGoalPos, aActivity ), AIN_NO_PATH_TASK_FAIL ) == false )
{
if ( m_hUnreachableObjects.Find( m_hPhysicsEnt ) == -1 )
m_hUnreachableObjects.AddToTail( m_hPhysicsEnt );
FindPhysicsObject( NULL, m_hPhysicsEnt );
m_flTimeToCatch = gpGlobals->curtime + 0.1;
m_flNextRouteTime = gpGlobals->curtime + 0.3;
m_flNextSwat = gpGlobals->curtime + 0.1;
GetNavigator()->ClearGoal();
}
else
{
TaskComplete();
}
}
break;
case TASK_DOG_FACE_OBJECT:
{
if( m_hPhysicsEnt == NULL )
{
// Physics Object is gone! Probably was an explosive
// or something else broke it.
TaskFail("Physics ent NULL");
return;
}
Vector vecDir;
vecDir = m_hPhysicsEnt->WorldSpaceCenter() - GetLocalOrigin();
VectorNormalize(vecDir);
GetMotor()->SetIdealYaw( UTIL_VecToYaw( vecDir ) );
TaskComplete();
}
break;
case TASK_DOG_PICKUP_ITEM:
{
if( m_hPhysicsEnt == NULL )
{
// Physics Object is gone! Probably was an explosive
// or something else broke it.
TaskFail("Physics ent NULL");
return;
}
else
{
SetIdealActivity( (Activity)ACT_DOG_PICKUP );
}
}
//.........这里部分代码省略.........
示例6: RunTask
//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_Dog::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_DOG_PICKUP_ITEM:
{
PullObject( false );
}
break;
case TASK_DOG_GET_PATH_TO_PHYSOBJ:
{
//Check this cause our object might have been deleted.
if ( m_hPhysicsEnt == NULL )
FindPhysicsObject( NULL );
//And if we still can't find anything, then just go away.
if ( m_hPhysicsEnt == NULL )
{
TaskFail( "Can't find an object I like!" );
return;
}
IPhysicsObject *pPhysicsObject = m_hPhysicsEnt->VPhysicsGetObject();
Vector vecGoalPos;
Vector vecDir;
vecDir = GetLocalOrigin() - m_hPhysicsEnt->WorldSpaceCenter();
VectorNormalize(vecDir);
vecDir.z = 0;
if ( m_hPhysicsEnt->GetOwnerEntity() == NULL )
m_hPhysicsEnt->SetOwnerEntity( this );
if ( pPhysicsObject )
pPhysicsObject->RecheckCollisionFilter();
vecGoalPos = m_hPhysicsEnt->WorldSpaceCenter() + (vecDir * DOG_PHYSOBJ_MOVE_TO_DIST );
bool bBuiltRoute = false;
//If I'm near my goal, then just walk to it.
Activity aActivity = ACT_RUN;
if ( ( vecGoalPos - GetLocalOrigin() ).Length() <= 128 )
aActivity = ACT_WALK;
bBuiltRoute = GetNavigator()->SetGoal( AI_NavGoal_t( vecGoalPos, aActivity ), AIN_NO_PATH_TASK_FAIL );
if ( bBuiltRoute == true )
TaskComplete();
else
{
m_flTimeToCatch = gpGlobals->curtime + 0.1;
m_flNextRouteTime = gpGlobals->curtime + 0.3;
m_flNextSwat = gpGlobals->curtime + 0.1;
if ( m_hUnreachableObjects.Find( m_hPhysicsEnt ) == -1 )
m_hUnreachableObjects.AddToTail( m_hPhysicsEnt );
m_hPhysicsEnt = NULL;
GetNavigator()->ClearGoal();
}
}
break;
case TASK_WAIT:
{
if ( IsWaitFinished() )
{
TaskComplete();
}
if ( m_hPhysicsEnt )
{
if ( m_bHasObject == false )
{
GetMotor()->SetIdealYawToTarget( m_hPhysicsEnt->GetAbsOrigin() );
GetMotor()->UpdateYaw();
}
}
break;
}
case TASK_DOG_LAUNCH_ITEM:
if( IsActivityFinished() )
{
if ( m_hPhysicsEnt )
{
m_hPhysicsEnt->SetOwnerEntity( NULL );
}
TaskComplete();
}
//.........这里部分代码省略.........