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.

101 lines
3.2 KiB

  1. //========= Copyright 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 *GetGlobalTFTeam( 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. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. //-----------------------------------------------------------------------------
  35. CCSTeam::~CCSTeam( void )
  36. {
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. void CCSTeam::Precache( void )
  42. {
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose: Called every frame
  46. //-----------------------------------------------------------------------------
  47. void CCSTeam::Think( void )
  48. {
  49. }
  50. //------------------------------------------------------------------------------------------------------------------
  51. // PLAYERS
  52. //-----------------------------------------------------------------------------
  53. // Purpose: Add the specified player to this team. Remove them from their current team, if any.
  54. //-----------------------------------------------------------------------------
  55. void CCSTeam::AddPlayer( CBasePlayer *pPlayer )
  56. {
  57. BaseClass::AddPlayer( pPlayer );
  58. }
  59. //-----------------------------------------------------------------------------
  60. // Purpose: Clean up the player's objects when they leave
  61. //-----------------------------------------------------------------------------
  62. void CCSTeam::RemovePlayer( CBasePlayer *pPlayer )
  63. {
  64. BaseClass::RemovePlayer( pPlayer );
  65. }
  66. //------------------------------------------------------------------------------------------------------------------
  67. // UTILITY FUNCS
  68. //-----------------------------------------------------------------------------
  69. //-----------------------------------------------------------------------------
  70. // Purpose:
  71. //-----------------------------------------------------------------------------
  72. CCSTeam* CCSTeam::GetEnemyTeam()
  73. {
  74. // Look for nearby enemy objects we can capture.
  75. int iMyTeam = GetTeamNumber();
  76. if( iMyTeam == 0 )
  77. return NULL;
  78. int iEnemyTeam = !(iMyTeam - 1) + 1;
  79. return (CCSTeam*)GetGlobalTeam( iEnemyTeam );
  80. }