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.

97 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Entity that propagates general data needed by clients for every player.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef C_PLAYERRESOURCE_H
  8. #define C_PLAYERRESOURCE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "shareddefs.h"
  13. #include "const.h"
  14. #include "c_baseentity.h"
  15. #include <igameresources.h>
  16. #define PLAYER_UNCONNECTED_NAME "unconnected"
  17. #define PLAYER_ERROR_NAME "ERRORNAME"
  18. class C_PlayerResource : public C_BaseEntity, public IGameResources, public IShaderDeviceDependentObject
  19. {
  20. DECLARE_CLASS( C_PlayerResource, C_BaseEntity );
  21. public:
  22. DECLARE_CLIENTCLASS();
  23. DECLARE_PREDICTABLE();
  24. C_PlayerResource();
  25. virtual ~C_PlayerResource();
  26. public : // IGameResources intreface
  27. // Team data access
  28. virtual int GetTeamScore( int index );
  29. virtual const char *GetTeamName( int index );
  30. virtual const Color&GetTeamColor( int index );
  31. // Player data access
  32. virtual bool IsConnected( int index );
  33. virtual bool IsAlive( int index );
  34. virtual bool IsFakePlayer( int index );
  35. virtual bool IsLocalPlayer( int index );
  36. virtual bool IsHLTV(int index);
  37. #if defined( REPLAY_ENABLED )
  38. virtual bool IsReplay(int index);
  39. #endif
  40. virtual const char *GetPlayerName( int index );
  41. virtual int GetPing( int index );
  42. // virtual int GetPacketloss( int index );
  43. virtual int GetKills( int index );
  44. virtual int GetAssists( int index );
  45. virtual int GetDeaths( int index );
  46. virtual int GetTeam( int index );
  47. virtual int GetPendingTeam( int index );
  48. virtual int GetFrags( int index );
  49. virtual int GetHealth( int index );
  50. virtual int GetCoachingTeam( int index );
  51. virtual void ClientThink();
  52. virtual void OnDataChanged(DataUpdateType_t updateType);
  53. virtual void DeviceLost( void );
  54. virtual void DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd );
  55. virtual void ScreenSizeChanged( int width, int height ) { }
  56. virtual void TeamChanged( void ){ }
  57. // Returns the xuid for the given player, but only if they are connected
  58. XUID GetXuid( int index );
  59. void FillXuidText( int iIndex, char *buf, int bufSize );
  60. protected:
  61. virtual void UpdatePlayerName( int slot );
  62. void UpdateAsLocalizedFakePlayerName( int slot, char const *pchRawPlayerName );
  63. void UpdateXuids( void );
  64. // Data for each player that's propagated to all clients
  65. // Stored in individual arrays so they can be sent down via datatables
  66. string_t m_szName[MAX_PLAYERS+1];
  67. int m_iPing[MAX_PLAYERS+1];
  68. int m_iKills[MAX_PLAYERS+1];
  69. int m_iAssists[MAX_PLAYERS+1];
  70. int m_iDeaths[MAX_PLAYERS+1];
  71. bool m_bConnected[MAX_PLAYERS+1];
  72. int m_iTeam[MAX_PLAYERS+1];
  73. int m_iPendingTeam[MAX_PLAYERS+1];
  74. bool m_bAlive[MAX_PLAYERS+1];
  75. int m_iHealth[MAX_PLAYERS+1];
  76. Color m_Colors[MAX_TEAMS];
  77. int m_iCoachingTeam[MAX_PLAYERS+1];
  78. XUID m_Xuids[MAX_PLAYERS+1];
  79. };
  80. extern C_PlayerResource *g_PR;
  81. #endif // C_PLAYERRESOURCE_H