本文整理汇总了C++中CBaseTFPlayer::IsInAVehicle方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTFPlayer::IsInAVehicle方法的具体用法?C++ CBaseTFPlayer::IsInAVehicle怎么用?C++ CBaseTFPlayer::IsInAVehicle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseTFPlayer
的用法示例。
在下文中一共展示了CBaseTFPlayer::IsInAVehicle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: FinishMove
//-----------------------------------------------------------------------------
// Purpose: This is called post player movement to copy back all data that
// movement could have modified and that is necessary for future
// movement. (Server-side, the client-side version of this code can
// be found in prediction.cpp.)
//-----------------------------------------------------------------------------
void CTFPlayerMove::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move )
{
// Call the default FinishMove code.
BaseClass::FinishMove( player, ucmd, move );
//
// Convert to TF2 data.
//
CBaseTFPlayer *pTFPlayer = static_cast<CBaseTFPlayer*>( player );
Assert( pTFPlayer );
CTFMoveData *pTFMove = static_cast<CTFMoveData*>( move );
Assert( pTFMove );
// The class had better not have changed during the move!!
Assert( pTFMove->m_nClassID == pTFPlayer->PlayerClass() );
IVehicle *pVehicle = player->GetVehicle();
if (!pVehicle)
{
// Handle player class specific setup.
switch( pTFPlayer->PlayerClass() )
{
case TFCLASS_RECON:
{
FinishMoveRecon( pTFPlayer, pTFMove, ucmd );
break;
}
case TFCLASS_COMMANDO:
{
FinishMoveCommando( pTFPlayer, pTFMove, ucmd );
break;
}
default:
{
break;
}
}
}
else
{
// Similarly, the vehicle had better not have changed during the move!
Assert( pTFPlayer->IsInAVehicle() );
pVehicle->FinishMove( pTFPlayer, ucmd, pTFMove );
}
//
// Player movement data.
//
// Copy the position delta.
pTFPlayer->m_vecPosDelta = pTFMove->m_vecPosDelta;
COMPILE_TIME_ASSERT( CBaseTFPlayer::MOMENTUM_MAXSIZE == CTFMoveData::MOMENTUM_MAXSIZE );
// Copy the momentum data back (the movement may have updated it!).
pTFPlayer->m_iMomentumHead = pTFMove->m_iMomentumHead;
for ( int iMomentum = 0; iMomentum < CTFMoveData::MOMENTUM_MAXSIZE; iMomentum++ )
{
pTFPlayer->m_aMomentum[iMomentum] = pTFMove->m_aMomentum[iMomentum];
}
}