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.

153 lines
4.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DOD_BOMBTARGET_H
  8. #define DOD_BOMBTARGET_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "baseanimating.h"
  13. #include "dod_control_point.h"
  14. #define DOD_BOMB_TARGET_MODEL_ARMED "models/weapons/w_tnt.mdl"
  15. #define DOD_BOMB_TARGET_MODEL_TARGET "models/weapons/w_tnt_red.mdl"
  16. #define DOD_BOMB_TARGET_MODEL_UNAVAILABLE "models/weapons/w_tnt_grey.mdl"
  17. class CDODBombTarget;
  18. class CDODBombTargetStateInfo
  19. {
  20. public:
  21. BombTargetState m_iState;
  22. const char *m_pStateName;
  23. void (CDODBombTarget::*pfnEnterState)(); // Init and deinit the state.
  24. void (CDODBombTarget::*pfnLeaveState)();
  25. void (CDODBombTarget::*pfnThink)(); // Do a PreThink() in this state.
  26. void (CDODBombTarget::*pfnUse)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  27. };
  28. struct DefusingPlayer
  29. {
  30. CHandle<CDODPlayer> m_pPlayer;
  31. float m_flDefuseTimeoutTime;
  32. float m_flDefuseCompleteTime;
  33. };
  34. class CDODBombTarget : public CBaseAnimating
  35. {
  36. public:
  37. DECLARE_CLASS( CDODBombTarget, CBaseAnimating );
  38. DECLARE_DATADESC();
  39. DECLARE_NETWORKCLASS();
  40. CDODBombTarget() {}
  41. virtual void Spawn( void );
  42. virtual void Precache( void );
  43. // Set these flags so players can use the bomb target ( for planting or defusing )
  44. virtual int ObjectCaps( void );
  45. // Inputs
  46. void InputEnable( inputdata_t &inputdata );
  47. void InputDisable( inputdata_t &inputdata );
  48. // State Functions
  49. void State_Transition( BombTargetState newState );
  50. void State_Enter( BombTargetState newState );
  51. void State_Leave();
  52. void State_Think();
  53. void State_Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  54. int State_Get( void ) { return m_iState; }
  55. CDODBombTargetStateInfo* State_LookupInfo( BombTargetState state );
  56. // Enter
  57. void State_Enter_INACTIVE( void );
  58. void State_Enter_ACTIVE( void );
  59. void State_Enter_ARMED( void );
  60. // Leave
  61. void State_Leave_Armed( void );
  62. // Think
  63. void State_Think_ARMED( void );
  64. // Use
  65. void State_Use_ACTIVE( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  66. void State_Use_ARMED( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  67. float GetBombTimerLength( void );
  68. // Get the dod_control_point that we're linked to
  69. CControlPoint *GetControlPoint( void );
  70. bool CanPlantHere( CDODPlayer *pPlayer );
  71. void CompletePlanting( CDODPlayer *pPlantingPlayer );
  72. void DefuseBlocked( CDODPlayer *pAttacker );
  73. void PlantBlocked( CDODPlayer *pAttacker );
  74. int GetTimerAddSeconds( void ) { return m_iTimerAddSeconds; }
  75. int GetBombingTeam( void ) { return m_iBombingTeam; }
  76. DefusingPlayer *FindDefusingPlayer( CDODPlayer *pPlayer );
  77. void Explode( void );
  78. void BombDefused( CDODPlayer *pDefuser );
  79. void ResetDefuse( int index );
  80. bool CanPlayerStartDefuse( CDODPlayer *pPlayer );
  81. bool CanPlayerContinueDefusing( CDODPlayer *pPlayer, DefusingPlayer *pDefuseRecord );
  82. private:
  83. // Control Point we're linked to
  84. string_t m_iszCapPointName;
  85. CControlPoint *m_pControlPoint;
  86. // Outputs
  87. COutputEvent m_OnBecomeActive;
  88. COutputEvent m_OnBecomeInactive;
  89. COutputEvent m_OnBombPlanted;
  90. COutputEvent m_OnBombExploded;
  91. COutputEvent m_OnBombDisarmed;
  92. // state
  93. CNetworkVar( int, m_iState );
  94. CDODBombTargetStateInfo *m_pCurStateInfo;
  95. bool m_bStartDisabled;
  96. // timers for armed state
  97. float m_flExplodeTime;
  98. float m_flNextAnnounce;
  99. // player that planted this bomb
  100. CHandle<CDODPlayer> m_pPlantingPlayer;
  101. // The team that is allowed to plant bombs here
  102. CNetworkVar( int, m_iBombingTeam );
  103. // network the model indices of active bomb so we can change per-team
  104. CNetworkVar( int, m_iTargetModel );
  105. CNetworkVar( int, m_iUnavailableModel );
  106. int m_iTimerAddSeconds;
  107. // List of defusing players and time until completion
  108. CUtlVector< DefusingPlayer > m_DefusingPlayers;
  109. private:
  110. CDODBombTarget( const CDODBombTarget & );
  111. };
  112. #endif //DOD_BOMBTARGET_H