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
6.1 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TEAM_OBJECTIVERESOURCE_H
  7. #define TEAM_OBJECTIVERESOURCE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "shareddefs.h"
  12. #define TEAM_ARRAY( index, team ) (index + (team * MAX_CONTROL_POINTS))
  13. //-----------------------------------------------------------------------------
  14. // Purpose: An entity that networks the state of the game's objectives.
  15. // May contain data for objectives that aren't used by your mod, but
  16. // the extra data will never be networked as long as it's zeroed out.
  17. //-----------------------------------------------------------------------------
  18. class CBaseTeamObjectiveResource : public CBaseEntity
  19. {
  20. DECLARE_CLASS( CBaseTeamObjectiveResource, CBaseEntity );
  21. public:
  22. DECLARE_SERVERCLASS();
  23. DECLARE_DATADESC();
  24. CBaseTeamObjectiveResource();
  25. ~CBaseTeamObjectiveResource();
  26. virtual void Spawn( void );
  27. virtual int UpdateTransmitState(void);
  28. virtual void ObjectiveThink( void );
  29. //--------------------------------------------------------------------
  30. // CONTROL POINT DATA
  31. //--------------------------------------------------------------------
  32. public:
  33. void ResetControlPoints( void );
  34. // Data functions, called to set up the state at the beginning of a round
  35. void SetNumControlPoints( int num );
  36. int GetNumControlPoints( void ) { return m_iNumControlPoints; }
  37. void SetCPIcons( int index, int iTeam, int iIcon );
  38. void SetCPOverlays( int index, int iTeam, int iIcon );
  39. void SetTeamBaseIcons( int iTeam, int iBaseIcon );
  40. void SetCPPosition( int index, const Vector& vPosition );
  41. void SetCPVisible( int index, bool bVisible );
  42. void SetCPRequiredCappers( int index, int iTeam, int iReqPlayers );
  43. void SetCPCapTime( int index, int iTeam, float flTime );
  44. void SetCPCapPercentage( int index, float flTime );
  45. float GetCPCapPercentage( int index );
  46. void SetTeamCanCap( int index, int iTeam, bool bCanCap );
  47. void SetBaseCP( int index, int iTeam );
  48. void SetPreviousPoint( int index, int iTeam, int iPrevIndex, int iPrevPoint );
  49. int GetPreviousPointForPoint( int index, int team, int iPrevIndex );
  50. bool TeamCanCapPoint( int index, int team );
  51. void SetCapLayoutInHUD( const char *pszLayout ) { Q_strncpy(m_pszCapLayoutInHUD.GetForModify(), pszLayout, MAX_CAPLAYOUT_LENGTH ); }
  52. void SetWarnOnCap( int index, int iWarnLevel );
  53. void SetWarnSound( int index, string_t iszSound );
  54. // State functions, called many times
  55. void SetNumPlayers( int index, int team, int iNumPlayers );
  56. void StartCap( int index, int team );
  57. void SetOwningTeam( int index, int team );
  58. void SetCappingTeam( int index, int team );
  59. void SetTeamInZone( int index, int team );
  60. void SetCapBlocked( int index, bool bBlocked );
  61. int GetOwningTeam( int index );
  62. void AssertValidIndex( int index )
  63. {
  64. Assert( 0 <= index && index <= MAX_CONTROL_POINTS && index < m_iNumControlPoints );
  65. }
  66. int GetBaseControlPointForTeam( int iTeam )
  67. {
  68. Assert( iTeam < MAX_TEAMS );
  69. return m_iBaseControlPoints[iTeam];
  70. }
  71. int GetCappingTeam( int index )
  72. {
  73. if ( index >= m_iNumControlPoints )
  74. return TEAM_UNASSIGNED;
  75. return m_iCappingTeam[index];
  76. }
  77. void SetTimerInHUD( CBaseEntity *pTimer )
  78. {
  79. m_iTimerToShowInHUD = pTimer ? pTimer->entindex() : 0;
  80. }
  81. void SetStopWatchTimer( CBaseEntity *pTimer )
  82. {
  83. m_iStopWatchTimer = pTimer ? pTimer->entindex() : 0;
  84. }
  85. int GetTimerInHUD( void ) { return m_iTimerToShowInHUD; }
  86. // Mini-rounds data
  87. void SetPlayingMiniRounds( bool bPlayingMiniRounds ){ m_bPlayingMiniRounds = bPlayingMiniRounds; }
  88. bool PlayingMiniRounds( void ){ return m_bPlayingMiniRounds; }
  89. void SetInMiniRound( int index, bool bInRound ) { m_bInMiniRound.Set( index, bInRound ); }
  90. bool IsInMiniRound( int index ) { return m_bInMiniRound[index]; }
  91. void UpdateCapHudElement( void );
  92. // Train Path data
  93. void SetTrainPathDistance( int index, float flDistance );
  94. private:
  95. CNetworkVar( int, m_iTimerToShowInHUD );
  96. CNetworkVar( int, m_iStopWatchTimer );
  97. CNetworkVar( int, m_iNumControlPoints );
  98. CNetworkVar( bool, m_bPlayingMiniRounds );
  99. CNetworkVar( bool, m_bControlPointsReset );
  100. CNetworkVar( int, m_iUpdateCapHudParity );
  101. // data variables
  102. CNetworkArray( Vector, m_vCPPositions, MAX_CONTROL_POINTS );
  103. CNetworkArray( int, m_bCPIsVisible, MAX_CONTROL_POINTS );
  104. CNetworkArray( float, m_flLazyCapPerc, MAX_CONTROL_POINTS );
  105. CNetworkArray( int, m_iTeamIcons, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS );
  106. CNetworkArray( int, m_iTeamOverlays, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS );
  107. CNetworkArray( int, m_iTeamReqCappers, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS );
  108. CNetworkArray( float, m_flTeamCapTime, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS );
  109. CNetworkArray( int, m_iPreviousPoints, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS * MAX_PREVIOUS_POINTS );
  110. CNetworkArray( bool, m_bTeamCanCap, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS );
  111. CNetworkArray( int, m_iTeamBaseIcons, MAX_TEAMS );
  112. CNetworkArray( int, m_iBaseControlPoints, MAX_TEAMS );
  113. CNetworkArray( bool, m_bInMiniRound, MAX_CONTROL_POINTS );
  114. CNetworkArray( int, m_iWarnOnCap, MAX_CONTROL_POINTS );
  115. CNetworkArray( string_t, m_iszWarnSound, MAX_CONTROL_POINTS );
  116. CNetworkArray( float, m_flPathDistance, MAX_CONTROL_POINTS );
  117. // change when players enter/exit an area
  118. CNetworkArray( int, m_iNumTeamMembers, MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS );
  119. // changes when a cap starts. start and end times are calculated on client
  120. CNetworkArray( int, m_iCappingTeam, MAX_CONTROL_POINTS );
  121. CNetworkArray( int, m_iTeamInZone, MAX_CONTROL_POINTS );
  122. CNetworkArray( bool, m_bBlocked, MAX_CONTROL_POINTS );
  123. // changes when a point is successfully captured
  124. CNetworkArray( int, m_iOwner, MAX_CONTROL_POINTS );
  125. // describes how to lay out the cap points in the hud
  126. CNetworkString( m_pszCapLayoutInHUD, MAX_CAPLAYOUT_LENGTH );
  127. // Not networked, because the client recalculates it
  128. float m_flCapPercentages[ MAX_CONTROL_POINTS ];
  129. };
  130. extern CBaseTeamObjectiveResource *g_pObjectiveResource;
  131. inline CBaseTeamObjectiveResource *ObjectiveResource()
  132. {
  133. return g_pObjectiveResource;
  134. }
  135. #endif // TEAM_OBJECTIVERESOURCE_H