Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cbase.h"
- #include "basenetworkedplayer_cl.h"
- #include "prediction.h"
- #include "c_basetempentity.h"
- #include "tom\tom_util.h"
- #undef CBaseNetworkedPlayer
- BEGIN_RECV_TABLE_NOBASE( C_BaseNetworkedPlayer, DT_BaseNetworkedPlayerExclusive )
- RecvPropVector( RECVINFO_NAME( m_vecNetworkOrigin, m_vecOrigin ) ), // RECVINFO_NAME copies the networked value over to the 'real' one
- RecvPropFloat( RECVINFO( m_angEyeAngles[0] ) ),
- // RecvPropFloat( RECVINFO( m_angEyeAngles[1] ) ),
- END_RECV_TABLE()
- BEGIN_RECV_TABLE_NOBASE( C_BaseNetworkedPlayer, DT_BaseNetworkedPlayerNonLocalExclusive )
- RecvPropVector( RECVINFO_NAME( m_vecNetworkOrigin, m_vecOrigin ) ), // RECVINFO_NAME again
- RecvPropFloat( RECVINFO( m_angEyeAngles[0] ) ),
- RecvPropFloat( RECVINFO( m_angEyeAngles[1] ) ),
- END_RECV_TABLE()
- IMPLEMENT_CLIENTCLASS_DT(C_BaseNetworkedPlayer, DT_BaseNetworkedPlayer, CBaseNetworkedPlayer )
- RecvPropBool( RECVINFO( m_bSpawnInterpCounter ) ),
- RecvPropDataTable( "netplayer_localdata", 0, 0, &REFERENCE_RECV_TABLE(DT_BaseNetworkedPlayerExclusive) ),
- RecvPropDataTable( "netplayer_nonlocaldata", 0, 0, &REFERENCE_RECV_TABLE(DT_BaseNetworkedPlayerNonLocalExclusive) ),
- END_NETWORK_TABLE()
- C_BaseNetworkedPlayer::C_BaseNetworkedPlayer() : m_iv_angEyeAngles( "C_BaseNetworkedPlayer::m_iv_angEyeAngles" )
- {
- AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR );
- m_bSpawnInterpCounterCache,m_bSpawnInterpCounter = false;
- };
- void C_BaseNetworkedPlayer::DoAnimationEvent( PlayerAnimEvent_t event, int nData )
- {
- if ( IsLocalPlayer() && prediction->InPrediction() && !prediction->IsFirstTimePredicted() )
- return;
- MDLCACHE_CRITICAL_SECTION();
- m_PlayerAnimState->DoAnimationEvent( event, nData );
- }
- void C_BaseNetworkedPlayer::UpdateClientSideAnimation() {
- BaseClass::UpdateClientSideAnimation();
- // Keep the model upright; pose params will handle pitch aiming.
- QAngle angles = GetLocalAngles();
- angles[PITCH] = 0;
- SetLocalAngles( angles );
- m_PlayerAnimState->Update( EyeAngles()[YAW], EyeAngles()[PITCH] );
- }
- void C_BaseNetworkedPlayer::PostDataUpdate( DataUpdateType_t updateType )
- {
- if ( m_bSpawnInterpCounter != m_bSpawnInterpCounterCache )
- {
- MoveToLastReceivedPosition( true );
- ResetLatched();
- m_bSpawnInterpCounterCache = m_bSpawnInterpCounter;
- }
- BaseClass::PostDataUpdate( updateType );
- }
- // -------------------------------------------------------------------------------- //
- // Player animation event. Sent to the client when a player fires, jumps, reloads, etc..
- // -------------------------------------------------------------------------------- //
- class C_TEPlayerAnimEvent : public C_BaseTempEntity
- {
- public:
- DECLARE_CLASS( C_TEPlayerAnimEvent, C_BaseTempEntity );
- DECLARE_CLIENTCLASS();
- virtual void PostDataUpdate( DataUpdateType_t updateType )
- {
- // Create the effect.
- C_BaseNetworkedPlayer *pPlayer = (C_BaseNetworkedPlayer*)m_hPlayer.Get();
- if ( pPlayer && !pPlayer->IsDormant() )
- {
- pPlayer->DoAnimationEvent( (PlayerAnimEvent_t)m_iEvent.Get(), m_nData );
- }
- }
- public:
- CNetworkHandle( CBasePlayer, m_hPlayer );
- CNetworkVar( int, m_iEvent );
- CNetworkVar( int, m_nData );
- };
- IMPLEMENT_CLIENTCLASS_EVENT( C_TEPlayerAnimEvent, DT_TEPlayerAnimEvent, CTEPlayerAnimEvent );
- BEGIN_RECV_TABLE_NOBASE( C_TEPlayerAnimEvent, DT_TEPlayerAnimEvent )
- RecvPropEHandle( RECVINFO( m_hPlayer ) ),
- RecvPropInt( RECVINFO( m_iEvent ) ),
- RecvPropInt( RECVINFO( m_nData ) )
- END_RECV_TABLE()
Advertisement
Add Comment
Please, Sign In to add comment