Counter Strike : Global Offensive Source Code
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.

168 lines
5.1 KiB

  1. //========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Round timer for team gamerules
  4. //
  5. //=============================================================================//
  6. #ifndef TEAM_ROUND_TIMER_H
  7. #define TEAM_ROUND_TIMER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #ifdef CLIENT_DLL
  12. #define CTeamRoundTimer C_TeamRoundTimer
  13. #endif
  14. class CTeamRoundTimer : public CBaseEntity
  15. {
  16. public:
  17. DECLARE_CLASS( CTeamRoundTimer, CBaseEntity );
  18. DECLARE_NETWORKCLASS();
  19. CTeamRoundTimer();
  20. virtual ~CTeamRoundTimer();
  21. virtual void Spawn( void );
  22. virtual void Precache( void );
  23. virtual void Activate( void );
  24. // Returns seconds to display.
  25. // When paused shows amount of time left once the timer is resumed
  26. virtual float GetTimeRemaining( void );
  27. virtual int GetTimerMaxLength( void );
  28. virtual bool ShowInHud( void );
  29. virtual bool StartPaused( void ){ return m_bStartPaused; }
  30. bool IsDisabled( void ) { return m_bIsDisabled; }
  31. int GetTimerState( void ){ return m_nState; }
  32. bool IsTimerPaused( void ) { return m_bTimerPaused; }
  33. #ifdef CLIENT_DLL
  34. void InternalSetPaused( bool bPaused ) { m_bTimerPaused = bPaused; }
  35. #else
  36. void SetStopWatchTimeStamp( void );
  37. virtual void SetTimeRemaining( int iTimerSeconds ); // Set the initial length of the timer
  38. virtual void AddTimerSeconds( int iSecondsToAdd, int iTeamResponsible = TEAM_UNASSIGNED ); // Add time to an already running ( or paused ) timer
  39. virtual void PauseTimer( void );
  40. virtual void ResumeTimer( void );
  41. virtual void SetAutoCountdown( bool bAuto ){ m_bAutoCountdown = bAuto; }
  42. void SetShowInHud( bool bShowInHUD ) { m_bShowInHUD = bShowInHUD; }
  43. int UpdateTransmitState();
  44. void InputEnable( inputdata_t &input );
  45. void InputDisable( inputdata_t &input );
  46. void InputPause( inputdata_t &input );
  47. void InputResume( inputdata_t &input );
  48. void InputSetTime( inputdata_t &input );
  49. void InputAddTime( inputdata_t &input );
  50. void InputRestart( inputdata_t &input );
  51. void InputShowInHUD( inputdata_t &input );
  52. void InputRoundSpawn( inputdata_t &inputdata );
  53. void InputSetMaxTime( inputdata_t &input );
  54. void InputAutoCountdown( inputdata_t &input );
  55. void InputAddTeamTime( inputdata_t &input );
  56. #endif
  57. void SetCaptureWatchState( bool bCaptureWatch );
  58. bool IsWatchingTimeStamps( void ) { return m_bInCaptureWatchState; }
  59. void SetStopWatch( bool bState ) { m_bStopWatchTimer = bState; }
  60. bool IsStopWatchTimer( void ) { return m_bStopWatchTimer; }
  61. float GetStopWatchTotalTime( void ) { return m_flTotalTime; }
  62. private:
  63. void CalculateOutputMessages( void );
  64. #ifdef CLIENT_DLL
  65. virtual void ClientThink();
  66. void OnPreDataChanged( DataUpdateType_t updateType );
  67. void OnDataChanged( DataUpdateType_t updateType );
  68. void SendTimeWarning( int nWarning );
  69. const char *GetTimeWarningSound( int nWarning );
  70. #else
  71. void SetState( int nState );
  72. void SetTimerThink( int nType );
  73. void EXPORT RoundTimerThink( void );
  74. void EXPORT RoundTimerSetupThink( void );
  75. static void SetActiveTimer( CTeamRoundTimer *pNewlyActive );
  76. #endif
  77. private:
  78. CNetworkVar( bool, m_bTimerPaused );
  79. CNetworkVar( float, m_flTimeRemaining );
  80. CNetworkVar( float, m_flTimerEndTime );
  81. CNetworkVar( bool, m_bIsDisabled );
  82. CNetworkVar( bool, m_bShowInHUD );
  83. CNetworkVar( int, m_nTimerLength ); // current timer's length (used in the timer panel if no max length is set)
  84. CNetworkVar( int, m_nTimerInitialLength ); // initial length of the timer
  85. CNetworkVar( int, m_nTimerMaxLength ); // max time the timer can have (0 is no max)
  86. CNetworkVar( bool, m_bAutoCountdown ); // automatically count down the end of a round
  87. CNetworkVar( int, m_nSetupTimeLength ); // current timer's setup time length (setup time is the time before the round begins)
  88. CNetworkVar( int, m_nState ); // RT_STATE_SETUP or RT_STATE_NORMAL
  89. CNetworkVar( bool, m_bStartPaused ); // start the timer paused when it spawns
  90. CNetworkVar( bool, m_bInCaptureWatchState );
  91. CNetworkVar( float, m_flTotalTime );
  92. CNetworkVar( bool, m_bStopWatchTimer );
  93. bool m_bFireFinished;
  94. bool m_bFire5MinRemain;
  95. bool m_bFire4MinRemain;
  96. bool m_bFire3MinRemain;
  97. bool m_bFire2MinRemain;
  98. bool m_bFire1MinRemain;
  99. bool m_bFire30SecRemain;
  100. bool m_bFire10SecRemain;
  101. bool m_bFire5SecRemain;
  102. bool m_bFire4SecRemain;
  103. bool m_bFire3SecRemain;
  104. bool m_bFire2SecRemain;
  105. bool m_bFire1SecRemain;
  106. #ifdef CLIENT_DLL
  107. int m_nOldTimerLength;
  108. int m_nOldTimerState;
  109. #else
  110. COutputEvent m_OnRoundStart;
  111. COutputEvent m_OnFinished;
  112. COutputEvent m_On5MinRemain;
  113. COutputEvent m_On4MinRemain;
  114. COutputEvent m_On3MinRemain;
  115. COutputEvent m_On2MinRemain;
  116. COutputEvent m_On1MinRemain;
  117. COutputEvent m_On30SecRemain;
  118. COutputEvent m_On10SecRemain;
  119. COutputEvent m_On5SecRemain;
  120. COutputEvent m_On4SecRemain;
  121. COutputEvent m_On3SecRemain;
  122. COutputEvent m_On2SecRemain;
  123. COutputEvent m_On1SecRemain;
  124. COutputEvent m_OnSetupStart;
  125. COutputEvent m_OnSetupFinished;
  126. DECLARE_DATADESC();
  127. bool m_bPauseDueToWin;
  128. bool m_bResetTimeOnRoundStart;
  129. int m_nTimeToUseAfterSetupFinished;
  130. #endif
  131. };
  132. #ifdef CLIENT_DLL
  133. extern CTeamRoundTimer *g_TeamRoundTimer;
  134. #endif
  135. #endif //TEAM_ROUND_TIMER_H