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.

138 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef TFC_PLAYER_SHARED_H
  7. #define TFC_PLAYER_SHARED_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "networkvar.h"
  12. #include "tfc_shareddefs.h"
  13. #include "weapon_tfcbase.h"
  14. #ifdef CLIENT_DLL
  15. class C_TFCPlayer;
  16. EXTERN_RECV_TABLE( DT_TFCPlayerShared );
  17. #else
  18. class CTFCPlayer;
  19. EXTERN_SEND_TABLE( DT_TFCPlayerShared );
  20. #endif
  21. // Data in the DoD player that is accessed by shared code.
  22. // This data isn't necessarily transmitted between client and server.
  23. class CTFCPlayerShared
  24. {
  25. public:
  26. #ifdef CLIENT_DLL
  27. friend class C_TFCPlayer;
  28. typedef C_TFCPlayer OuterClass;
  29. DECLARE_PREDICTABLE();
  30. #else
  31. friend class CTFCPlayer;
  32. typedef CTFCPlayer OuterClass;
  33. #endif
  34. DECLARE_EMBEDDED_NETWORKVAR()
  35. DECLARE_CLASS_NOBASE( CTFCPlayerShared );
  36. CTFCPlayerShared();
  37. void Init( OuterClass *pOuter );
  38. void SetPlayerClass( int playerclass );
  39. int GetPlayerClass() const;
  40. const CTFCPlayerClassInfo* GetClassInfo() const;
  41. // State.
  42. TFCPlayerState State_Get() const;
  43. // State flags (TFSTATE_).
  44. int GetStateFlags() const;
  45. void SetStateFlags( int val );
  46. void AddStateFlags( int flags );
  47. void RemoveStateFlags( int flags );
  48. // Item flags (IT_).
  49. int GetItemFlags() const;
  50. void SetItemFlags( int val );
  51. void AddItemFlags( int val );
  52. void RemoveItemFlags( int val );
  53. CWeaponTFCBase* GetActiveTFCWeapon() const;
  54. // Vars that are networked.
  55. private:
  56. CNetworkVar( int, m_StateFlags ); // Combination of the TFSTATE_ flags.
  57. CNetworkVar( int, m_ItemFlags );
  58. CNetworkVar( int, m_iPlayerClass );
  59. CNetworkVar( TFCPlayerState, m_iPlayerState );
  60. // Vars that aren't networked.
  61. public:
  62. private:
  63. OuterClass *m_pOuter;
  64. };
  65. inline int CTFCPlayerShared::GetStateFlags() const
  66. {
  67. return m_StateFlags;
  68. }
  69. inline void CTFCPlayerShared::SetStateFlags( int val )
  70. {
  71. m_StateFlags = val;
  72. }
  73. inline void CTFCPlayerShared::AddStateFlags( int flags )
  74. {
  75. m_StateFlags |= flags;
  76. }
  77. inline void CTFCPlayerShared::RemoveStateFlags( int flags )
  78. {
  79. m_StateFlags &= ~flags;
  80. }
  81. inline int CTFCPlayerShared::GetItemFlags() const
  82. {
  83. return m_ItemFlags;
  84. }
  85. inline void CTFCPlayerShared::SetItemFlags( int val )
  86. {
  87. m_ItemFlags = val;
  88. }
  89. inline void CTFCPlayerShared::AddItemFlags( int val )
  90. {
  91. m_ItemFlags |= val;
  92. }
  93. inline void CTFCPlayerShared::RemoveItemFlags( int val )
  94. {
  95. m_ItemFlags &= ~val;
  96. }
  97. inline const CTFCPlayerClassInfo* CTFCPlayerShared::GetClassInfo() const
  98. {
  99. return GetTFCClassInfo( GetPlayerClass() );
  100. }
  101. #endif // TFC_PLAYER_SHARED_H