本文整理汇总了C++中EHANDLE::SetOwnerEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ EHANDLE::SetOwnerEntity方法的具体用法?C++ EHANDLE::SetOwnerEntity怎么用?C++ EHANDLE::SetOwnerEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EHANDLE
的用法示例。
在下文中一共展示了EHANDLE::SetOwnerEntity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DropGrenade
void CNPC_Zombine::DropGrenade( Vector vDir )
{
if ( m_hGrenade == NULL )
return;
m_hGrenade->SetParent( NULL );
m_hGrenade->SetOwnerEntity( NULL );
Vector vGunPos;
QAngle angles;
GetAttachment( "grenade_attachment", vGunPos, angles );
IPhysicsObject *pPhysObj = m_hGrenade->VPhysicsGetObject();
if ( pPhysObj == NULL )
{
m_hGrenade->SetMoveType( MOVETYPE_VPHYSICS );
m_hGrenade->SetSolid( SOLID_VPHYSICS );
m_hGrenade->SetCollisionGroup( COLLISION_GROUP_WEAPON );
m_hGrenade->CreateVPhysics();
}
if ( pPhysObj )
{
pPhysObj->Wake();
pPhysObj->SetPosition( vGunPos, angles, true );
pPhysObj->ApplyForceCenter( vDir * 0.2f );
pPhysObj->RecheckCollisionFilter();
}
m_hGrenade = NULL;
}
示例2: PrescheduleThink
void CNPC_Dog::PrescheduleThink( void )
{
BaseClass::PrescheduleThink();
if ( m_hPhysicsEnt )
{
IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();
if ( pPhysObj && pPhysObj->GetGameFlags() & FVPHYSICS_PLAYER_HELD )
{
m_hPhysicsEnt->SetOwnerEntity( NULL );
}
}
if ( m_flTimeToCatch < gpGlobals->curtime )
m_flTimeToCatch = 0.0f;
if ( GetIdealActivity() == ACT_IDLE )
{
if ( m_hPhysicsEnt && m_bHasObject == true )
{
SetIdealActivity( (Activity)ACT_DOG_WAITING );
}
}
}
示例3: InputPickup
//-----------------------------------------------------------------------------
// Purpose: Pick up a specified object
// Input : &inputdata -
//-----------------------------------------------------------------------------
void CNPC_CombineDropship::InputPickup( inputdata_t &inputdata )
{
// Can't pickup if we're already carrying something
if ( m_hContainer )
{
Warning("npc_combinedropship %s was told to pickup, but is already carrying something.\n", STRING(GetEntityName()) );
return;
}
string_t iszTargetName = inputdata.value.StringID();
if ( iszTargetName == NULL_STRING )
{
Warning("npc_combinedropship %s tried to pickup with no specified pickup target.\n", STRING(GetEntityName()) );
return;
}
CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, iszTargetName, NULL );
if ( !pTarget )
{
Warning("npc_combinedropship %s couldn't find pickup target named %s\n", STRING(GetEntityName()), STRING(iszTargetName) );
return;
}
// Start heading to the point
m_hPickupTarget = pTarget;
// Disable collisions to my target
m_hPickupTarget->SetOwnerEntity(this);
if ( m_NPCState == NPC_STATE_IDLE )
{
SetState( NPC_STATE_ALERT );
}
m_iLandState = LANDING_SWOOPING;
m_flLandingSpeed = GetAbsVelocity().Length();
}
示例4: CleanCatchAndThrow
void CNPC_Dog::CleanCatchAndThrow( bool bClearTimers )
{
if ( m_hPhysicsEnt )
{
if ( m_bHasObject == true )
{
IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();
m_hPhysicsEnt->SetParent( NULL );
m_hPhysicsEnt->SetOwnerEntity( NULL );
Vector vGunPos;
QAngle angGunAngles;
GetAttachment( m_iPhysGunAttachment, vGunPos, angGunAngles );
if ( pPhysObj )
{
pPhysObj->Wake();
pPhysObj->RemoveShadowController();
pPhysObj->SetPosition( vGunPos, angGunAngles, true );
}
else
{
Warning( "CleanCatchAndThrow: m_hPhysicsEnt->VPhysicsGetObject == NULL!\n" );
}
m_hPhysicsEnt->SetMoveType( (MoveType_t)m_iContainerMoveType );
if ( pPhysObj )
{
pPhysObj->RecheckCollisionFilter();
}
ClearBeams();
}
m_hPhysicsEnt = NULL;
}
if ( bClearTimers == true )
{
m_bDoCatchThrowBehavior = false;
m_bDoWaitforObjectBehavior = false;
m_flTimeToCatch = 0.0f;
m_flNextSwat = 0.0f;
SetCondition( COND_DOG_LOST_PHYSICS_ENTITY );
}
}
示例5: PickupOrCatchObject
void CNPC_Dog::PickupOrCatchObject( const char *pAttachmentName )
{
if ( m_hPhysicsEnt )
{
InvalidateBoneCache();
int iAttachment = LookupAttachment( pAttachmentName );
if ( iAttachment == 0 )
iAttachment = m_iPhysGunAttachment;
// Move physobject to shadow
IPhysicsObject *pPhysicsObject = m_hPhysicsEnt->VPhysicsGetObject();
if ( pPhysicsObject )
{
pPhysicsObject->SetShadow( 1e4, 1e4, false, false );
pPhysicsObject->UpdateShadow( GetAbsOrigin(), GetAbsAngles(), false, 0 );
}
m_iContainerMoveType = m_hPhysicsEnt->GetMoveType();
m_hPhysicsEnt->SetMoveType( MOVETYPE_NONE );
m_hPhysicsEnt->SetParent( this, iAttachment );
m_hPhysicsEnt->SetLocalOrigin( vec3_origin );
m_hPhysicsEnt->SetLocalAngles( vec3_angle );
m_hPhysicsEnt->SetGroundEntity( NULL );
if ( m_hPhysicsEnt->GetOwnerEntity() == NULL )
m_hPhysicsEnt->SetOwnerEntity( this );
if ( pPhysicsObject )
pPhysicsObject->RecheckCollisionFilter();
m_bHasObject = true;
//Fire Output!
m_OnPickup.FireOutput( this, this );
}
}
示例6: ThrowObject
void CNPC_Dog::ThrowObject( const char *pAttachmentName )
{
if ( m_hPhysicsEnt )
{
m_bHasObject = false;
IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject();
if ( pPhysObj )
{
Vector vGunPos;
QAngle angGunAngles;
AngularImpulse angVelocity = RandomAngularImpulse( -250 , -250 ) / pPhysObj->GetMass();
InvalidateBoneCache();
int iAttachment = LookupAttachment( pAttachmentName );
if ( iAttachment == 0 )
iAttachment = m_iPhysGunAttachment;
GetAttachment( iAttachment, vGunPos, angGunAngles );
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" );
//.........这里部分代码省略.........
示例7: 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 );
}
示例8: 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 );
}
}
//.........这里部分代码省略.........
示例9: 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();
}
//.........这里部分代码省略.........
示例10: Spawn
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_CombineDropship::Spawn( void )
{
Precache( );
SetModel( "models/combine_dropship.mdl" );
BaseClass::Spawn();
ExtractBbox( SelectHeaviestSequence( ACT_DROPSHIP_DEPLOY_IDLE ), m_cullBoxMins, m_cullBoxMaxs );
BaseClass::Spawn();
InitPathingData( DROPSHIP_LEAD_DISTANCE, DROPSHIP_MIN_CHASE_DIST_DIFF, DROPSHIP_AVOID_DIST );
// create the correct bin for the ship to carry
switch ( m_iCrateType )
{
case CRATE_ROLLER_HOPPER:
break;
case CRATE_SOLDIER:
m_hContainer = CreateEntityByName( "prop_dynamic" );
if ( m_hContainer )
{
m_hContainer->SetModel( "models/props_junk/trashdumpster02.mdl" );
m_hContainer->SetLocalOrigin( GetAbsOrigin() );
m_hContainer->SetLocalAngles( GetLocalAngles() );
m_hContainer->SetAbsAngles( GetAbsAngles() );
m_hContainer->SetParent(this, 0);
m_hContainer->SetOwnerEntity(this);
m_hContainer->SetSolid( SOLID_VPHYSICS );
m_hContainer->Spawn();
}
break;
case CRATE_NONE:
default:
break;
}
m_iHealth = 100;
m_flFieldOfView = 0.5; // 60 degrees
m_iContainerMoveType = MOVETYPE_NONE;
//InitBoneControllers();
InitCustomSchedules();
if ( m_hContainer )
{
SetIdealActivity( (Activity)ACT_DROPSHIP_FLY_IDLE_CARGO );
}
else
{
SetIdealActivity( (Activity)ACT_DROPSHIP_FLY_IDLE_EXAGG );
}
m_flMaxSpeed = DROPSHIP_MAX_SPEED;
m_flMaxSpeedFiring = BASECHOPPER_MAX_FIRING_SPEED;
m_hPickupTarget = NULL;
//!!!HACKHACK
// This tricks the AI code that constantly complains that the vehicle has no schedule.
SetSchedule( SCHED_IDLE_STAND );
m_iLandState = LANDING_NO;
}