当前位置: 首页>>代码示例>>C++>>正文


C++ CBaseTFPlayer::GetVehicle方法代码示例

本文整理汇总了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;
}
开发者ID:,项目名称:,代码行数:74,代码来源:


注:本文中的CBaseTFPlayer::GetVehicle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。