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.

284 lines
7.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef C_DOD_PLAYER_H
  7. #define C_DOD_PLAYER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "dod_playeranimstate.h"
  12. #include "c_baseplayer.h"
  13. #include "dod_shareddefs.h"
  14. #include "baseparticleentity.h"
  15. #include "dod_player_shared.h"
  16. #include "beamdraw.h"
  17. #include "hintsystem.h"
  18. #define PRONE_MAX_SWAY 3.0
  19. #define PRONE_SWAY_AMOUNT 4.0
  20. #define RECOIL_DURATION 0.1
  21. class CViewAngleAnimation;
  22. class C_DODPlayer : public C_BasePlayer
  23. {
  24. public:
  25. friend class CDODPlayerShared;
  26. DECLARE_CLASS( C_DODPlayer, C_BasePlayer );
  27. DECLARE_CLIENTCLASS();
  28. DECLARE_PREDICTABLE();
  29. DECLARE_INTERPOLATION();
  30. C_DODPlayer();
  31. ~C_DODPlayer();
  32. static C_DODPlayer* GetLocalDODPlayer();
  33. virtual const QAngle& GetRenderAngles();
  34. virtual void UpdateClientSideAnimation();
  35. virtual void ProcessMuzzleFlashEvent();
  36. virtual void PostDataUpdate( DataUpdateType_t updateType );
  37. virtual bool CreateMove( float flInputSampleTime, CUserCmd *pCmd );
  38. virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
  39. virtual void OnDataChanged( DataUpdateType_t type );
  40. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  41. virtual void ClientThink( void );
  42. virtual void GetToolRecordingState( KeyValues *msg );
  43. void LocalPlayerRespawn( void );
  44. // Returns true if we're allowed to show the menus right now.
  45. bool CanShowTeamMenu() const { return true; }
  46. bool CanShowClassMenu();
  47. bool ShouldDraw( void );
  48. virtual C_BaseAnimating * BecomeRagdollOnClient();
  49. virtual IRagdoll* GetRepresentativeRagdoll() const;
  50. virtual void ReceiveMessage( int classID, bf_read &msg );
  51. void PopHelmet( Vector vecDir, Vector vecForceOffset, int model );
  52. // Get the ID target entity index. The ID target is the player that is behind our crosshairs, used to
  53. // display the player's name.
  54. int GetIDTarget() const
  55. {
  56. return m_iIDEntIndex;
  57. }
  58. void UpdateIDTarget();
  59. bool ShouldAutoReload( void );
  60. bool ShouldAutoRezoom( void );
  61. void SetSprinting( bool bIsSprinting );
  62. bool IsSprinting( void );
  63. void LowerWeapon( void );
  64. void RaiseWeapon( void );
  65. bool IsWeaponLowered( void );
  66. virtual ShadowType_t ShadowCastType( void );
  67. virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
  68. virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
  69. virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
  70. virtual int DrawModel( int flags );
  71. virtual void Simulate();
  72. virtual float GetMinFOV() const { return 20; }
  73. virtual bool SetFOV( CBaseEntity *pRequester, int FOV, float zoomRate = 0.0f );
  74. virtual void CreateLightEffects( void ) {} //no dimlight effects
  75. virtual Vector GetChaseCamViewOffset( CBaseEntity *target );
  76. virtual const QAngle& EyeAngles();
  77. virtual const Vector& GetRenderOrigin(); // return ragdoll origin if dead
  78. bool dod_IsInterpolationEnabled( void ) { return IsInterpolationEnabled(); }
  79. void CreateViewAngleAnimations( void );
  80. void CheckGrenadeHint( Vector vecGrenadeOrigin );
  81. void CheckBombTargetPlantHint( void );
  82. void CheckBombTargetDefuseHint( void );
  83. virtual void ComputeWorldSpaceSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs );
  84. // Hints
  85. virtual CHintSystem *Hints( void ) { return &m_Hints; }
  86. // Player avoidance
  87. bool ShouldCollide( int collisionGroup, int contentsMask ) const;
  88. void AvoidPlayers( CUserCmd *pCmd );
  89. virtual bool ShouldReceiveProjectedTextures( int flags )
  90. {
  91. return ( this != C_BasePlayer::GetLocalPlayer() );
  92. }
  93. bool IsNemesisOfLocalPlayer();
  94. bool ShouldShowNemesisIcon();
  95. virtual void OnAchievementAchieved( int iAchievement );
  96. int GetActiveAchievementAward( void );
  97. IMaterial *GetHeadIconMaterial( void );
  98. protected:
  99. virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  100. void CalcDODDeathCamView( Vector &eyeOrigin, QAngle& eyeAngles, float& fov );
  101. void CalcChaseCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
  102. virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  103. // Called by shared code.
  104. public:
  105. void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
  106. DODPlayerState State_Get() const;
  107. IDODPlayerAnimState *m_PlayerAnimState;
  108. QAngle m_angEyeAngles;
  109. CInterpolatedVar< QAngle > m_iv_angEyeAngles;
  110. void FireBullets( const FireBulletsInfo_t &info );
  111. bool CanAttack( void );
  112. void SetBazookaDeployed( bool bDeployed ) {}
  113. // the control point index the player is near
  114. int GetCPIndex( void ) { return m_Shared.GetCPIndex(); }
  115. //Implemented in shared code
  116. public:
  117. virtual void SharedSpawn();
  118. void CheckProneMoveSound( int groundspeed, bool onground );
  119. virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity );
  120. virtual void PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force );
  121. virtual const Vector GetPlayerMins( void ) const; // uses local player
  122. virtual const Vector GetPlayerMaxs( void ) const; // uses local player
  123. // Returns true if the player is allowed to move.
  124. bool CanMove() const;
  125. float GetStamina( void ) const;
  126. void SetStamina( float flStamina );
  127. virtual void SetAnimation( PLAYER_ANIM playerAnim );
  128. CDODPlayerShared m_Shared;
  129. float m_flRecoilTimeRemaining;
  130. float m_flPitchRecoilAccumulator;
  131. float m_flYawRecoilAccumulator;
  132. void GetWeaponRecoilAmount( int weaponId, float &flPitchRecoil, float &flYawRecoil );
  133. void DoRecoil( int iWpnID, float flWpnRecoil );
  134. void SetRecoilAmount( float flPitchRecoil, float flYawRecoil );
  135. void GetRecoilToAddThisFrame( float &flPitchRecoil, float &flYawRecoil );
  136. EHANDLE m_hRagdoll;
  137. CWeaponDODBase* GetActiveDODWeapon() const;
  138. Activity TranslateActivity( Activity baseAct, bool *pRequired = NULL );
  139. Vector m_lastStandingPos; // used by the gamemovement code for finding ladders
  140. // for stun effect
  141. float m_flStunEffectTime;
  142. float m_flStunAlpha;
  143. CNetworkVar( float, m_flStunMaxAlpha );
  144. CNetworkVar( float, m_flStunDuration );
  145. float GetDeathTime( void ) { return m_flDeathTime; }
  146. // How long the progress bar takes to get to the end. If this is 0, then the progress bar
  147. // should not be drawn.
  148. CNetworkVar( int, m_iProgressBarDuration );
  149. // When the progress bar should start.
  150. CNetworkVar( float, m_flProgressBarStartTime );
  151. float m_flLastRespawnTime;
  152. private:
  153. C_DODPlayer( const C_DODPlayer & );
  154. CNetworkVar( DODPlayerState, m_iPlayerState );
  155. CNetworkVar( float, m_flStamina );
  156. float m_flProneViewOffset;
  157. bool m_bProneSwayingRight;
  158. Vector m_vecRagdollVelocity;
  159. // ID Target
  160. int m_iIDEntIndex;
  161. bool m_bWeaponLowered; // should our weapon be lowered right now
  162. CNetworkVar( bool, m_bSpawnInterpCounter );
  163. bool m_bSpawnInterpCounterCache;
  164. CHintSystem m_Hints;
  165. void ReleaseFlashlight( void );
  166. Beam_t *m_pFlashlightBeam;
  167. float m_flMinNextStepSoundTime;
  168. float m_fNextThinkPushAway;
  169. bool m_bPlayingProneMoveSound;
  170. void StaminaSoundThink( void );
  171. CSoundPatch *m_pStaminaSound;
  172. bool m_bPlayingLowStaminaSound;
  173. // Cold Breath
  174. bool CreateColdBreathEmitter( void );
  175. void DestroyColdBreathEmitter( void );
  176. void UpdateColdBreath( void );
  177. void EmitColdBreathParticles( void );
  178. bool m_bColdBreathOn;
  179. float m_flColdBreathTimeStart;
  180. float m_flColdBreathTimeEnd;
  181. CSmartPtr<CSimpleEmitter> m_hColdBreathEmitter;
  182. PMaterialHandle m_hColdBreathMaterial;
  183. int m_iHeadAttach;
  184. float m_flHideHeadIconUntilTime;
  185. virtual void CalculateIKLocks( float currentTime );
  186. int m_iAchievementAwardsMask;
  187. IMaterial *m_pHeadIconMaterial;
  188. };
  189. inline C_DODPlayer *ToDODPlayer( CBaseEntity *pEntity )
  190. {
  191. if ( !pEntity || !pEntity->IsPlayer() )
  192. return NULL;
  193. return dynamic_cast<C_DODPlayer*>( pEntity );
  194. }
  195. #endif // C_DOD_PLAYER_H