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.

128 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: CTF Flag Capture Zone.
  4. //
  5. //=============================================================================//
  6. #ifndef FUNC_CAPTURE_ZONE_H
  7. #define FUNC_CAPTURE_ZONE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "triggers.h"
  12. // This class is to get around the fact that DEFINE_FUNCTION doesn't like multiple inheritance
  13. class CCaptureZoneShim : public CBaseTrigger
  14. {
  15. virtual void ShimTouch( CBaseEntity *pOther ) = 0;
  16. public:
  17. void Touch( CBaseEntity *pOther ) { return ShimTouch( pOther ) ; }
  18. };
  19. //=============================================================================
  20. //
  21. // CTF Flag Capture Zone class.
  22. //
  23. DECLARE_AUTO_LIST( ICaptureZoneAutoList );
  24. class CCaptureZone : public CCaptureZoneShim, public ICaptureZoneAutoList
  25. {
  26. DECLARE_CLASS( CCaptureZone, CCaptureZoneShim );
  27. public:
  28. DECLARE_SERVERCLASS();
  29. CCaptureZone();
  30. void Spawn();
  31. virtual void Activate();
  32. virtual void ShimTouch( CBaseEntity *pOther ) OVERRIDE;
  33. void Capture( CBaseEntity *pOther );
  34. bool IsDisabled( void );
  35. void SetDisabled( bool bDisabled );
  36. // Input handlers
  37. void InputEnable( inputdata_t &inputdata );
  38. void InputDisable( inputdata_t &inputdata );
  39. int UpdateTransmitState( void );
  40. void PlayerDestructionThink( void );
  41. private:
  42. CNetworkVar( bool, m_bDisabled ); // Enabled/Disabled?
  43. int m_nCapturePoint; // Used in non-CTF maps to identify this capture point
  44. COutputEvent m_outputOnCapture; // Fired a flag is captured on this point.
  45. COutputEvent m_OnCapTeam1;
  46. COutputEvent m_OnCapTeam2;
  47. COutputEvent m_OnCapTeam1_PD;
  48. COutputEvent m_OnCapTeam2_PD;
  49. DECLARE_DATADESC();
  50. float m_flNextTouchingEnemyZoneWarning; // don't spew warnings to the player who is touching the wrong cap
  51. bool m_bShouldBlock;
  52. float m_flCaptureDelay;
  53. float m_flCaptureDelayOffset;
  54. };
  55. //=============================================================================
  56. //
  57. // CTF Flag Detection Zone class.
  58. //
  59. DECLARE_AUTO_LIST( IFlagDetectionZoneAutoList );
  60. class CFlagDetectionZone : public CBaseTrigger, public IFlagDetectionZoneAutoList
  61. {
  62. DECLARE_CLASS( CFlagDetectionZone, CBaseTrigger );
  63. public:
  64. CFlagDetectionZone();
  65. void Spawn();
  66. void StartTouch( CBaseEntity *pOther );
  67. void EndTouch( CBaseEntity *pOther );
  68. bool IsDisabled( void ) { return m_bDisabled; }
  69. void SetDisabled( bool bDisabled );
  70. bool IsAlarmZone( void ){ return m_bShouldAlarm; }
  71. // Input handlers
  72. void InputEnable( inputdata_t &inputdata );
  73. void InputDisable( inputdata_t &inputdata );
  74. void InputTest( inputdata_t &inputdata );
  75. void FlagDropped( CBasePlayer *pPlayer );
  76. void FlagPickedUp( CBasePlayer *pPlayer );
  77. void FlagCaptured( CBasePlayer *pPlayer );
  78. private:
  79. bool EntityIsFlagCarrier( CBaseEntity *pEntity );
  80. bool m_bDisabled; // Enabled/Disabled?
  81. bool m_bShouldAlarm;
  82. COutputEvent m_outputOnStartTouchFlag; // Fired when a flag or player holding the flag touches
  83. COutputEvent m_outputOnEndTouchFlag;
  84. COutputEvent m_outputOnDroppedFlag;
  85. COutputEvent m_outputOnPickedUpFlag;
  86. // Entities currently being touched by this trigger
  87. CUtlVector< EHANDLE > m_hTouchingPlayers;
  88. DECLARE_DATADESC();
  89. };
  90. // Fire output for detection zones if entity is in a the zone
  91. void HandleFlagDroppedInDetectionZone( CBasePlayer *pPlayer );
  92. void HandleFlagPickedUpInDetectionZone( CBasePlayer *pPlayer );
  93. void HandleFlagCapturedInDetectionZone( CBasePlayer *pPlayer );
  94. #endif // FUNC_CAPTURE_ZONE_H