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.

108 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Team management class. Contains all the details for a specific team
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "cs_team.h"
  9. #include "entitylist.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. // Datatable
  13. IMPLEMENT_SERVERCLASS_ST(CCSTeam, DT_CSTeam)
  14. END_SEND_TABLE()
  15. LINK_ENTITY_TO_CLASS( cs_team_manager, CCSTeam );
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Get a pointer to the specified TF team manager
  18. //-----------------------------------------------------------------------------
  19. CCSTeam *GetGlobalCSTeam( int iIndex )
  20. {
  21. return (CCSTeam*)GetGlobalTeam( iIndex );
  22. }
  23. //-----------------------------------------------------------------------------
  24. // Purpose: Needed because this is an entity, but should never be used
  25. //-----------------------------------------------------------------------------
  26. void CCSTeam::Init( const char *pName, int iNumber )
  27. {
  28. BaseClass::Init( pName, iNumber );
  29. // Only detect changes every half-second.
  30. NetworkProp()->SetUpdateInterval( 0.75f );
  31. }
  32. CCSTeam::CCSTeam()
  33. {
  34. }
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. //-----------------------------------------------------------------------------
  38. CCSTeam::~CCSTeam( void )
  39. {
  40. }
  41. //-----------------------------------------------------------------------------
  42. // Purpose:
  43. //-----------------------------------------------------------------------------
  44. void CCSTeam::Precache( void )
  45. {
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose: Called every frame
  49. //-----------------------------------------------------------------------------
  50. void CCSTeam::Think( void )
  51. {
  52. BaseClass::Think();
  53. }
  54. void CCSTeam::OnRoundPreStart( void )
  55. {
  56. }
  57. //------------------------------------------------------------------------------------------------------------------
  58. // PLAYERS
  59. //-----------------------------------------------------------------------------
  60. // Purpose: Add the specified player to this team. Remove them from their current team, if any.
  61. //-----------------------------------------------------------------------------
  62. void CCSTeam::AddPlayer( CBasePlayer *pPlayer )
  63. {
  64. BaseClass::AddPlayer( pPlayer );
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Purpose: Clean up the player's objects when they leave
  68. //-----------------------------------------------------------------------------
  69. void CCSTeam::RemovePlayer( CBasePlayer *pPlayer )
  70. {
  71. BaseClass::RemovePlayer( pPlayer );
  72. }
  73. //------------------------------------------------------------------------------------------------------------------
  74. // UTILITY FUNCS
  75. //-----------------------------------------------------------------------------
  76. //-----------------------------------------------------------------------------
  77. // Purpose:
  78. //-----------------------------------------------------------------------------
  79. CCSTeam* CCSTeam::GetEnemyTeam()
  80. {
  81. int iMyTeam = GetTeamNumber();
  82. if ( iMyTeam == TEAM_CT )
  83. return GetGlobalCSTeam( TEAM_TERRORIST );
  84. else if ( iMyTeam == TEAM_TERRORIST )
  85. return GetGlobalCSTeam( TEAM_CT );
  86. else
  87. return NULL;
  88. }