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.

146 lines
4.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Entities for use in the Robot Destruction TF2 game mode.
  4. //
  5. //=========================================================================//
  6. #ifndef PLAYER_DESTRUCTION_H
  7. #define PLAYER_DESTRUCTION_H
  8. #pragma once
  9. #include "cbase.h"
  10. #include "tf_logic_robot_destruction.h"
  11. #ifdef CLIENT_DLL
  12. #define CTFPlayerDestructionLogic C_TFPlayerDestructionLogic
  13. #define CPlayerDestructionDispenser C_PlayerDestructionDispenser
  14. #endif
  15. //-----------------------------------------------------------------------------
  16. class CTFPlayerDestructionLogic : public CTFRobotDestructionLogic
  17. {
  18. public:
  19. #ifdef GAME_DLL
  20. DECLARE_DATADESC();
  21. #endif // GAME_DLL
  22. DECLARE_CLASS( CTFPlayerDestructionLogic, CTFRobotDestructionLogic )
  23. DECLARE_NETWORKCLASS();
  24. virtual EType GetType() const { return TYPE_PLAYER_DESTRUCTION; }
  25. CTFPlayerDestructionLogic();
  26. static CTFPlayerDestructionLogic* GetPlayerDestructionLogic();
  27. CTFPlayer* GetRedTeamLeader() const { return m_hRedTeamLeader.Get(); }
  28. CTFPlayer* GetBlueTeamLeader() const { return m_hBlueTeamLeader.Get(); }
  29. #ifdef GAME_DLL
  30. virtual void Precache() OVERRIDE;
  31. const char *GetPropModelName() const;
  32. void CalcTeamLeader( int iTeam );
  33. virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;
  34. void InputScoreRedPoints( inputdata_t& inputdata );
  35. void InputScoreBluePoints( inputdata_t& inputdata );
  36. void InputEnableMaxScoreUpdating( inputdata_t& inputdata );
  37. void InputDisableMaxScoreUpdating( inputdata_t& inputdata );
  38. void InputSetCountdownTimer( inputdata_t& inputdata );
  39. void InputSetCountdownImage( inputdata_t& inputdata );
  40. void InputSetFlagResetDelay( inputdata_t& inputdata );
  41. void InputSetPointsOnPlayerDeath( inputdata_t& inputdata );
  42. void PlayPropDropSound( CTFPlayer *pPlayer );
  43. void PlayPropPickupSound( CTFPlayer *pPlayer );
  44. void CountdownThink( void );
  45. int GetFlagResetDelay( void ){ return m_nFlagResetDelay; }
  46. int GetPointsOnPlayerDeath( void ){ return m_nPointsOnPlayerDeath; }
  47. virtual int GetHealDistance( void ) OVERRIDE { return m_nHealDistance; }
  48. virtual void TeamWin( int nTeam ) OVERRIDE;
  49. #endif // GAME_DLL
  50. CTFPlayer *GetTeamLeader( int iTeam ) const OVERRIDE;
  51. string_t GetCountdownImage( void ) OVERRIDE { return m_iszCountdownImage; }
  52. virtual bool IsUsingCustomCountdownImage( void ) OVERRIDE{ return m_bUsingCountdownImage; }
  53. private:
  54. #ifdef GAME_DLL
  55. void PlaySound( const char *pszSound, CTFPlayer *pPlayer );
  56. virtual void OnRedScoreChanged() OVERRIDE;
  57. virtual void OnBlueScoreChanged() OVERRIDE;
  58. void EvaluatePlayerCount();
  59. void SetCountdownImage( string_t iszCountdownImage ) { m_iszCountdownImage = iszCountdownImage; }
  60. string_t m_iszPropModelName;
  61. string_t m_iszPropDropSound;
  62. string_t m_iszPropPickupSound;
  63. int m_nMinPoints;
  64. int m_nPointsPerPlayer;
  65. bool m_bMaxScoreUpdatingAllowed;
  66. int m_nFlagResetDelay;
  67. int m_nHealDistance;
  68. CObjectDispenser* CreateDispenser( int iTeam );
  69. CHandle< CObjectDispenser > m_hRedDispenser;
  70. CHandle< CObjectDispenser > m_hBlueDispenser;
  71. COutputFloat m_OnRedScoreChanged;
  72. COutputFloat m_OnBlueScoreChanged;
  73. COutputEvent m_OnCountdownTimerExpired;
  74. #endif // GAME_DLL
  75. CNetworkVar( CHandle<CTFPlayer>, m_hRedTeamLeader );
  76. CNetworkVar( CHandle<CTFPlayer>, m_hBlueTeamLeader );
  77. CNetworkVar( bool, m_bUsingCountdownImage );
  78. #ifdef CLIENT_DLL
  79. char m_iszCountdownImage[MAX_PATH];
  80. #else
  81. CNetworkVar( string_t, m_iszCountdownImage );
  82. int m_nPointsOnPlayerDeath;
  83. #endif
  84. };
  85. class CPlayerDestructionDispenser :
  86. #ifdef GAME_DLL
  87. public CObjectDispenser
  88. #else
  89. public C_ObjectDispenser
  90. #endif
  91. {
  92. #ifdef GAME_DLL
  93. DECLARE_CLASS( CPlayerDestructionDispenser, CObjectDispenser )
  94. #else
  95. DECLARE_CLASS( CPlayerDestructionDispenser, C_ObjectDispenser )
  96. #endif
  97. DECLARE_NETWORKCLASS();
  98. DECLARE_DATADESC();
  99. public:
  100. #ifdef GAME_DLL
  101. virtual float GetDispenserRadius( void ) OVERRIDE
  102. {
  103. if ( CTFPlayerDestructionLogic::GetRobotDestructionLogic() && ( CTFPlayerDestructionLogic::GetRobotDestructionLogic()->GetType() == CTFPlayerDestructionLogic::TYPE_PLAYER_DESTRUCTION ) )
  104. {
  105. return CTFPlayerDestructionLogic::GetRobotDestructionLogic()->GetHealDistance();
  106. }
  107. return 450;
  108. }
  109. virtual void Spawn( void ) OVERRIDE;
  110. void OnGoActive( void ) OVERRIDE;
  111. void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName ) OVERRIDE;
  112. #endif
  113. };
  114. #endif// PLAYER_DESTRUCTION_H