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. #ifndef TEAM_H
  8. #define TEAM_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "shareddefs.h"
  13. #include "utlvector.h"
  14. class CBasePlayer;
  15. class CTeamSpawnPoint;
  16. class CTeam : public CBaseEntity
  17. {
  18. DECLARE_CLASS( CTeam, CBaseEntity );
  19. public:
  20. CTeam( void );
  21. virtual ~CTeam( void );
  22. DECLARE_SERVERCLASS();
  23. virtual void Precache( void ) { return; };
  24. virtual void Think( void );
  25. virtual int UpdateTransmitState( void );
  26. //-----------------------------------------------------------------------------
  27. // Initialization
  28. //-----------------------------------------------------------------------------
  29. virtual void Init( const char *pName, int iNumber );
  30. //-----------------------------------------------------------------------------
  31. // Data Handling
  32. //-----------------------------------------------------------------------------
  33. virtual int GetTeamNumber( void ) const;
  34. virtual const char *GetName( void ) const;
  35. virtual void UpdateClientData( CBasePlayer *pPlayer );
  36. virtual bool ShouldTransmitToPlayer( CBasePlayer* pRecipient, CBaseEntity* pEntity ) const;
  37. //-----------------------------------------------------------------------------
  38. // Spawnpoints
  39. //-----------------------------------------------------------------------------
  40. virtual void InitializeSpawnpoints( void );
  41. virtual void AddSpawnpoint( CTeamSpawnPoint *pSpawnpoint );
  42. virtual void RemoveSpawnpoint( CTeamSpawnPoint *pSpawnpoint );
  43. virtual CBaseEntity *SpawnPlayer( CBasePlayer *pPlayer );
  44. //-----------------------------------------------------------------------------
  45. // Players
  46. //-----------------------------------------------------------------------------
  47. virtual void InitializePlayers( void );
  48. virtual void AddPlayer( CBasePlayer *pPlayer );
  49. virtual void RemovePlayer( CBasePlayer *pPlayer );
  50. virtual int GetNumPlayers( void ) const;
  51. virtual CBasePlayer *GetPlayer( int iIndex ) const ;
  52. //-----------------------------------------------------------------------------
  53. // Scoring
  54. //-----------------------------------------------------------------------------
  55. virtual void AddScore( int iScore );
  56. virtual void SetScore( int iScore );
  57. virtual int GetScore( void ) const;
  58. virtual void ResetScores( void );
  59. // Round scoring
  60. virtual int GetRoundsWon( void ) const { return m_iRoundsWon; }
  61. virtual void SetRoundsWon( int iRounds ) { m_iRoundsWon = iRounds; }
  62. virtual void IncrementRoundsWon( void ) { m_iRoundsWon++; }
  63. void AwardAchievement( int iAchievement );
  64. virtual int GetAliveMembers( void ) const;
  65. public:
  66. CUtlVector< CTeamSpawnPoint * > m_aSpawnPoints;
  67. CUtlVector< CBasePlayer * > m_aPlayers;
  68. // Data
  69. CNetworkString( m_szTeamname, MAX_TEAM_NAME_LENGTH );
  70. CNetworkVar( int, m_iScore );
  71. CNetworkVar( int, m_iRoundsWon );
  72. int m_iDeaths;
  73. // Spawnpoints
  74. int m_iLastSpawn; // Index of the last spawnpoint used
  75. CNetworkVar( int, m_iTeamNum ); // Which team is this?
  76. };
  77. extern CUtlVector< CTeam * > g_Teams;
  78. extern CTeam *GetGlobalTeam( int iIndex );
  79. extern int GetNumberOfTeams( void );
  80. #endif // TEAM_H