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.

265 lines
7.2 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef C_TEAM_OBJECTIVERESOURCE_H
  7. #define C_TEAM_OBJECTIVERESOURCE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "shareddefs.h"
  12. #include "const.h"
  13. #include "c_baseentity.h"
  14. #include <igameresources.h>
  15. #define TEAM_ARRAY( index, team ) (index + (team * MAX_CONTROL_POINTS))
  16. //-----------------------------------------------------------------------------
  17. // Purpose: An entity that networks the state of the game's objectives.
  18. // May contain data for objectives that aren't used by your mod, but
  19. // the extra data will never be networked as long as it's zeroed out.
  20. //-----------------------------------------------------------------------------
  21. class C_BaseTeamObjectiveResource : public C_BaseEntity
  22. {
  23. DECLARE_CLASS( C_BaseTeamObjectiveResource, C_BaseEntity );
  24. public:
  25. DECLARE_CLIENTCLASS();
  26. C_BaseTeamObjectiveResource();
  27. virtual ~C_BaseTeamObjectiveResource();
  28. public:
  29. virtual void ClientThink();
  30. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  31. virtual void OnDataChanged( DataUpdateType_t updateType );
  32. void UpdateControlPoint( const char *pszEvent, int index = -1 );
  33. float GetCPCapPercentage( int index );
  34. int GetNumControlPoints( void ) { return m_iNumControlPoints; }
  35. int GetNumControlPointsOwned( void );
  36. void SetOwningTeam( int index, int team );
  37. virtual void SetCappingTeam( int index, int team );
  38. void SetCapLayout( const char *pszLayout );
  39. // Is the point visible in the objective display
  40. bool IsCPVisible( int index )
  41. {
  42. Assert( index < m_iNumControlPoints );
  43. return m_bCPIsVisible[index];
  44. }
  45. bool IsCPBlocked( int index )
  46. {
  47. Assert( index < m_iNumControlPoints );
  48. return m_bBlocked[index];
  49. }
  50. // Get the world location of this control point
  51. Vector& GetCPPosition( int index )
  52. {
  53. Assert( index < m_iNumControlPoints );
  54. return m_vCPPositions[index];
  55. }
  56. int GetOwningTeam( int index )
  57. {
  58. if ( index >= m_iNumControlPoints )
  59. return TEAM_UNASSIGNED;
  60. return m_iOwner[index];
  61. }
  62. int GetCappingTeam( int index )
  63. {
  64. if ( index >= m_iNumControlPoints )
  65. return TEAM_UNASSIGNED;
  66. return m_iCappingTeam[index];
  67. }
  68. int GetTeamInZone( int index )
  69. {
  70. if ( index >= m_iNumControlPoints )
  71. return TEAM_UNASSIGNED;
  72. return m_iTeamInZone[index];
  73. }
  74. // Icons
  75. int GetCPCurrentOwnerIcon( int index, int iOwner )
  76. {
  77. Assert( index < m_iNumControlPoints );
  78. return GetIconForTeam( index, iOwner );
  79. }
  80. int GetCPCappingIcon( int index )
  81. {
  82. Assert( index < m_iNumControlPoints );
  83. int iCapper = GetCappingTeam(index);
  84. Assert( iCapper != TEAM_UNASSIGNED );
  85. return GetIconForTeam( index, iCapper );;
  86. }
  87. // Icon for the specified team
  88. int GetIconForTeam( int index, int team )
  89. {
  90. Assert( index < m_iNumControlPoints );
  91. return m_iTeamIcons[ TEAM_ARRAY(index,team) ];
  92. }
  93. // Overlay for the specified team
  94. int GetOverlayForTeam( int index, int team )
  95. {
  96. Assert( index < m_iNumControlPoints );
  97. return m_iTeamOverlays[ TEAM_ARRAY(index,team) ];
  98. }
  99. // Number of players in the area
  100. int GetNumPlayersInArea( int index, int team )
  101. {
  102. Assert( index < m_iNumControlPoints );
  103. return m_iNumTeamMembers[ TEAM_ARRAY(index,team) ];
  104. }
  105. // get the required cappers for the passed team
  106. int GetRequiredCappers( int index, int team )
  107. {
  108. Assert( index < m_iNumControlPoints );
  109. return m_iTeamReqCappers[ TEAM_ARRAY(index,team) ];
  110. }
  111. // Base Icon for the specified team
  112. int GetBaseIconForTeam( int team )
  113. {
  114. Assert( team < MAX_TEAMS );
  115. return m_iTeamBaseIcons[ team ];
  116. }
  117. int GetBaseControlPointForTeam( int iTeam )
  118. {
  119. Assert( iTeam < MAX_TEAMS );
  120. return m_iBaseControlPoints[iTeam];
  121. }
  122. int GetPreviousPointForPoint( int index, int team, int iPrevIndex )
  123. {
  124. Assert( index < m_iNumControlPoints );
  125. Assert( iPrevIndex >= 0 && iPrevIndex < MAX_PREVIOUS_POINTS );
  126. int iIntIndex = iPrevIndex + (index * MAX_PREVIOUS_POINTS) + (team * MAX_CONTROL_POINTS * MAX_PREVIOUS_POINTS);
  127. return m_iPreviousPoints[ iIntIndex ];
  128. }
  129. bool TeamCanCapPoint( int index, int team )
  130. {
  131. Assert( index < m_iNumControlPoints );
  132. return m_bTeamCanCap[ TEAM_ARRAY( index, team ) ];
  133. }
  134. const char *GetCapLayoutInHUD( void ) { return m_pszCapLayoutInHUD; }
  135. bool PlayingMiniRounds( void ){ return m_bPlayingMiniRounds; }
  136. bool IsInMiniRound( int index ) { return m_bInMiniRound[index]; }
  137. int GetCapWarningLevel( int index )
  138. {
  139. Assert( index < m_iNumControlPoints );
  140. return m_iWarnOnCap[index];
  141. }
  142. const char *GetWarnSound( int index )
  143. {
  144. Assert( index < m_iNumControlPoints );
  145. return m_iszWarnSound[index];
  146. }
  147. virtual const char *GetGameSpecificCPCappingSwipe( int index, int iCappingTeam )
  148. {
  149. // You need to implement this in your game's objective resource.
  150. Assert(0);
  151. return NULL;
  152. }
  153. virtual const char *GetGameSpecificCPBarFG( int index, int iOwningTeam )
  154. {
  155. // You need to implement this in your game's objective resource.
  156. Assert(0);
  157. return NULL;
  158. }
  159. virtual const char *GetGameSpecificCPBarBG( int index, int iCappingTeam )
  160. {
  161. // You need to implement this in your game's objective resource.
  162. Assert(0);
  163. return NULL;
  164. }
  165. bool CapIsBlocked( int index );
  166. int GetTimerToShowInHUD( void ) { return m_iTimerToShowInHUD; }
  167. int GetStopWatchTimer( void ) { return m_iStopWatchTimer; }
  168. float GetPathDistance( int index )
  169. {
  170. Assert( index < m_iNumControlPoints );
  171. return m_flPathDistance[index];
  172. }
  173. protected:
  174. int m_iTimerToShowInHUD;
  175. int m_iStopWatchTimer;
  176. int m_iNumControlPoints;
  177. int m_iPrevNumControlPoints;
  178. bool m_bPlayingMiniRounds;
  179. bool m_bControlPointsReset;
  180. bool m_bOldControlPointsReset;
  181. int m_iUpdateCapHudParity;
  182. int m_iOldUpdateCapHudParity;
  183. // data variables
  184. Vector m_vCPPositions[MAX_CONTROL_POINTS];
  185. bool m_bCPIsVisible[MAX_CONTROL_POINTS];
  186. float m_flLazyCapPerc[MAX_CONTROL_POINTS];
  187. float m_flOldLazyCapPerc[MAX_CONTROL_POINTS];
  188. int m_iTeamIcons[MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS];
  189. int m_iTeamOverlays[MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS];
  190. int m_iTeamReqCappers[MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS];
  191. float m_flTeamCapTime[MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS];
  192. int m_iPreviousPoints[ MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS * MAX_PREVIOUS_POINTS ];
  193. bool m_bTeamCanCap[ MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS ];
  194. int m_iTeamBaseIcons[MAX_TEAMS];
  195. int m_iBaseControlPoints[MAX_TEAMS];
  196. bool m_bInMiniRound[MAX_CONTROL_POINTS];
  197. int m_iWarnOnCap[MAX_CONTROL_POINTS];
  198. char m_iszWarnSound[MAX_CONTROL_POINTS][255];
  199. float m_flPathDistance[MAX_CONTROL_POINTS];
  200. // state variables
  201. int m_iNumTeamMembers[MAX_CONTROL_POINTS * MAX_CONTROL_POINT_TEAMS];
  202. int m_iCappingTeam[MAX_CONTROL_POINTS];
  203. int m_iTeamInZone[MAX_CONTROL_POINTS];
  204. bool m_bBlocked[MAX_CONTROL_POINTS];
  205. int m_iOwner[MAX_CONTROL_POINTS];
  206. // client calculated state
  207. float m_flCapTimeLeft[MAX_CONTROL_POINTS];
  208. float m_flCapLastThinkTime[MAX_CONTROL_POINTS];
  209. bool m_bWarnedOnFinalCap[MAX_CONTROL_POINTS];
  210. float m_flLastCapWarningTime[MAX_CONTROL_POINTS];
  211. char m_pszCapLayoutInHUD[MAX_CAPLAYOUT_LENGTH];
  212. };
  213. extern C_BaseTeamObjectiveResource *g_pObjectiveResource;
  214. inline C_BaseTeamObjectiveResource *ObjectiveResource()
  215. {
  216. return g_pObjectiveResource;
  217. }
  218. #endif // C_TEAM_OBJECTIVERESOURCE_H