//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && ShouldDrawLocalPlayerViewModel() ) // TODO: figure out the purpose of the ShouldDrawLocalPlayer() test. { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { int overrideModelIndex = CalcOverrideModelIndex(); if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() ) { SetModelIndex( overrideModelIndex ); } } if ( updateType == DATA_UPDATE_CREATED ) { UpdateVisibility(); } m_iOldState = m_iState; m_bJustRestored = false; }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && !ShouldDrawLocalPlayer() ) { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { // BRJ 10/14/02 // FIXME: Remove when Yahn's client-side prediction is done // It's a hacky workaround for the model indices fighting // (GetRenderBounds uses the model index, which is for the view model) SetModelIndex( GetWorldModelIndex() ); } UpdateVisibility(); m_iOldState = m_iState; m_bJustRestored = false; }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && !ShouldDrawLocalPlayer() ) { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { // See comment below EnsureCorrectRenderingModel(); } UpdateVisibility(); m_iOldState = m_iState; m_bJustRestored = false; }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BaseCombatCharacter *pOwner = GetOwner(); C_BasePlayer *pPlayer = ToBasePlayer( pOwner ); // check if weapon is carried by local player bool bIsLocalPlayer = C_BasePlayer::IsLocalPlayer( pPlayer ); if ( bIsLocalPlayer ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) ); // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( ( m_iState != WEAPON_NOT_CARRIED ) && ( m_iOldState == WEAPON_NOT_CARRIED ) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } UpdateVisibility(); m_iOldState = m_iState; m_bJustRestored = false; }