本文整理汇总了C++中CBaseTFPlayer::GetVehicle方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTFPlayer::GetVehicle方法的具体用法?C++ CBaseTFPlayer::GetVehicle怎么用?C++ CBaseTFPlayer::GetVehicle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseTFPlayer
的用法示例。
在下文中一共展示了CBaseTFPlayer::GetVehicle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldTransmit
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CEnvLaserDesignation::ShouldTransmit( const edict_t *recipient, const void *pvs, int clientArea )
{
// Only transmit to players who care about laser designation:
// - Player designating
// - Players in tanks
// - Commandos
CBaseEntity* pRecipientEntity = CBaseEntity::Instance( recipient );
if ( pRecipientEntity->IsPlayer() )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)pRecipientEntity;
// Designating player?
if ( pPlayer == GetOwnerEntity() )
return true;
if ( !InSameTeam( pPlayer ) )
return false;
// In a tank?
if ( pPlayer->IsInAVehicle() )
{
CBaseEntity *pVehicle = pPlayer->GetVehicle()->GetVehicleEnt();
if ( dynamic_cast<CVehicleTank*>(pVehicle) )
{
// Make sure it's within range of the tank's fire
static float flTankRange = 0;
if ( !flTankRange )
{
flTankRange = vehicle_tank_range.GetFloat() * weapon_grenade_rocket_track_range_mod.GetFloat();
flTankRange *= flTankRange;
}
float flDistanceSqr = ( GetAbsOrigin() - pPlayer->GetAbsOrigin() ).LengthSqr();
if ( flDistanceSqr < flTankRange )
return true;
}
else if ( dynamic_cast<CObjectMannedMissileLauncher*>(pVehicle) )
{
// Make sure it's within range of the manned missile launcher's fire
static float flGunRange = 0;
if ( !flGunRange )
{
flGunRange = obj_manned_missilelauncher_range_off.GetFloat() * weapon_grenade_rocket_track_range_mod.GetFloat();
flGunRange *= flGunRange;
}
float flDistanceSqr = ( GetAbsOrigin() - pPlayer->GetAbsOrigin() ).LengthSqr();
if ( flDistanceSqr < flGunRange )
return true;
}
}
// Is the player a commando?
if ( pPlayer->PlayerClass() == TFCLASS_COMMANDO )
{
// Make sure it's within range of the commando's rockets
static float flCommandoRange = 0;
if ( !flCommandoRange )
{
flCommandoRange = weapon_rocket_launcher_range.GetFloat() * weapon_grenade_rocket_track_range_mod.GetFloat();
flCommandoRange *= flCommandoRange;
}
float flDistanceSqr = ( GetAbsOrigin() - pPlayer->GetAbsOrigin() ).LengthSqr();
if ( flDistanceSqr < flCommandoRange )
return true;
}
}
return false;
}