Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Player for SDK Game
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SDK_PLAYER_H
  8. #define SDK_PLAYER_H
  9. #pragma once
  10. #include "player.h"
  11. #include "server_class.h"
  12. #include "sdk_playeranimstate.h"
  13. #include "sdk_shareddefs.h"
  14. //=============================================================================
  15. // >> SDK Game player
  16. //=============================================================================
  17. class CSDKPlayer : public CBasePlayer, public ISDKPlayerAnimStateHelpers
  18. {
  19. public:
  20. DECLARE_CLASS( CSDKPlayer, CBasePlayer );
  21. DECLARE_SERVERCLASS();
  22. DECLARE_PREDICTABLE();
  23. DECLARE_DATADESC();
  24. CSDKPlayer();
  25. ~CSDKPlayer();
  26. static CSDKPlayer *CreatePlayer( const char *className, edict_t *ed );
  27. static CSDKPlayer* Instance( int iEnt );
  28. // This passes the event to the client's and server's CPlayerAnimState.
  29. void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
  30. virtual void FlashlightTurnOn( void );
  31. virtual void FlashlightTurnOff( void );
  32. virtual int FlashlightIsOn( void );
  33. virtual void PreThink();
  34. virtual void PostThink();
  35. virtual void Spawn();
  36. virtual void InitialSpawn();
  37. virtual void Precache();
  38. virtual void Event_Killed( const CTakeDamageInfo &info );
  39. virtual void LeaveVehicle( const Vector &vecExitPoint, const QAngle &vecExitAngles );
  40. CWeaponSDKBase* GetActiveSDKWeapon() const;
  41. virtual void CreateViewModel( int viewmodelindex = 0 );
  42. virtual void CheatImpulseCommands( int iImpulse );
  43. CNetworkVar( int, m_iThrowGrenadeCounter ); // used to trigger grenade throw animations.
  44. CNetworkQAngle( m_angEyeAngles ); // Copied from EyeAngles() so we can send it to the client.
  45. CNetworkVar( int, m_iShotsFired ); // number of shots fired recently
  46. // Tracks our ragdoll entity.
  47. CNetworkHandle( CBaseEntity, m_hRagdoll ); // networked entity handle
  48. // In shared code.
  49. public:
  50. // ISDKPlayerAnimState overrides.
  51. virtual CWeaponSDKBase* SDKAnim_GetActiveWeapon();
  52. virtual bool SDKAnim_CanMove();
  53. void FireBullet(
  54. Vector vecSrc,
  55. const QAngle &shootAngles,
  56. float vecSpread,
  57. int iDamage,
  58. int iBulletType,
  59. CBaseEntity *pevAttacker,
  60. bool bDoEffects,
  61. float x,
  62. float y );
  63. private:
  64. void CreateRagdollEntity();
  65. ISDKPlayerAnimState *m_PlayerAnimState;
  66. };
  67. inline CSDKPlayer *ToSDKPlayer( CBaseEntity *pEntity )
  68. {
  69. if ( !pEntity || !pEntity->IsPlayer() )
  70. return NULL;
  71. #ifdef _DEBUG
  72. Assert( dynamic_cast<CSDKPlayer*>( pEntity ) != 0 );
  73. #endif
  74. return static_cast< CSDKPlayer* >( pEntity );
  75. }
  76. #endif // SDK_PLAYER_H