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.

93 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // The copyright to the contents herein is the property of Valve, L.L.C.
  4. // The contents may be used and/or copied only with the written permission of
  5. // Valve, L.L.C., or in accordance with the terms and conditions stipulated in
  6. // the agreement/contract under which the contents have been supplied.
  7. //
  8. // Purpose: Revive
  9. //
  10. // $Workfile: $
  11. // $Date: $
  12. // $NoKeywords: $
  13. //=============================================================================
  14. #ifndef TF_REVIVE_H
  15. #define TF_REVIVE_H
  16. #ifdef _WIN32
  17. #pragma once
  18. #endif
  19. #ifdef CLIENT_DLL
  20. #include "c_tf_player.h"
  21. #else
  22. #include "tf_player.h"
  23. #endif
  24. #ifdef CLIENT_DLL
  25. #define CTFReviveMarker C_TFReviveMarker
  26. #endif
  27. //-----------------------------------------------------------------------------
  28. //
  29. //-----------------------------------------------------------------------------
  30. class CTFReviveMarker : public CBaseAnimating
  31. {
  32. DECLARE_DATADESC();
  33. DECLARE_NETWORKCLASS();
  34. DECLARE_CLASS( CTFReviveMarker, CBaseAnimating );
  35. public:
  36. CTFReviveMarker();
  37. virtual void Precache() OVERRIDE;
  38. virtual void Spawn( void ) OVERRIDE;
  39. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
  40. virtual bool IsCombatItem( void ) const { return true; }
  41. #ifdef GAME_DLL
  42. static CTFReviveMarker *Create( CTFPlayer *pOwner );
  43. virtual int UpdateTransmitState( void ) OVERRIDE;
  44. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo ) OVERRIDE;
  45. void ReviveThink( void );
  46. #else
  47. virtual void OnDataChanged( DataUpdateType_t updateType ) OVERRIDE;
  48. virtual int GetHealth( void ) const OVERRIDE { return m_iHealth; }
  49. virtual int GetMaxHealth( void ) const OVERRIDE { return m_iMaxHealth; }
  50. virtual bool IsVisibleToTargetID( void ) const OVERRIDE { return true; }
  51. #endif // GAME_DLL
  52. void SetOwner( CTFPlayer *pPlayer );
  53. void SetReviver( CTFPlayer *pPlayer ) { m_pReviver = pPlayer; }
  54. CTFPlayer *GetOwner( void ) const { return m_hOwner; }
  55. CTFPlayer *GetReviver( void ) const { return m_pReviver; }
  56. #ifdef GAME_DLL
  57. void AddMarkerHealth( float flAmount );
  58. bool IsReviveInProgress( void );
  59. // Fully healed. Ask player if they'd like to be revived at their marker.
  60. bool ReviveOwner( void );
  61. void PromptOwner( void );
  62. bool HasOwnerBeenPrompted( void ) { return m_bOwnerPromptedToRevive; }
  63. void SetOwnerHasBeenPrompted( bool bValue ) { m_bOwnerPromptedToRevive = bValue; }
  64. #endif // GAME_DLL
  65. private:
  66. CNetworkHandle( CTFPlayer, m_hOwner );
  67. CTFPlayer *m_pReviver;
  68. CNetworkVar( uint16, m_nRevives );
  69. #ifdef GAME_DLL
  70. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_iHealth );
  71. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_iMaxHealth );
  72. float m_flHealAccumulator;
  73. bool m_bOwnerPromptedToRevive;
  74. float m_flLastHealTime;
  75. bool m_bOnGround;
  76. #else
  77. int m_iHealth;
  78. int m_iMaxHealth;
  79. bool m_bCalledForMedic;
  80. #endif // CLIENT_DLL
  81. };
  82. #endif // TF_REVIVE_H