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.

135 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // TF Grappling Hook
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_GRAPPLINGHOOK_H
  7. #define TF_WEAPON_GRAPPLINGHOOK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weapon_rocketlauncher.h"
  12. #ifdef CLIENT_DLL
  13. #include "econ_notifications.h"
  14. #define CTFGrapplingHook C_TFGrapplingHook
  15. #endif // CLIENT_DLL
  16. // ------------------------------------------------------------------------------------------------------------------------
  17. class CTFGrapplingHook : public CTFRocketLauncher
  18. {
  19. public:
  20. DECLARE_CLASS( CTFGrapplingHook, CTFRocketLauncher );
  21. DECLARE_NETWORKCLASS();
  22. DECLARE_PREDICTABLE();
  23. // Server specific.
  24. #ifdef GAME_DLL
  25. DECLARE_DATADESC();
  26. #endif // GAME_DLL
  27. CTFGrapplingHook();
  28. virtual void Precache() OVERRIDE;
  29. virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer ) OVERRIDE;
  30. virtual void ItemPostFrame( void ) OVERRIDE;
  31. virtual bool CanAttack( void ) OVERRIDE;
  32. virtual void PrimaryAttack( void ) OVERRIDE;
  33. virtual bool Deploy( void ) OVERRIDE;
  34. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo ) OVERRIDE;
  35. virtual void GetProjectileFireSetup( CTFPlayer *pPlayer, Vector vecOffset, Vector *vecSrc, QAngle *angForward, bool bHitTeammates = true, float flEndDist = 2000.f ) OVERRIDE;
  36. virtual int GetWeaponID( void ) const OVERRIDE { return TF_WEAPON_GRAPPLINGHOOK; }
  37. virtual float GetProjectileSpeed( void ) OVERRIDE;
  38. virtual float GetProjectileGravity( void ) OVERRIDE { return 0.f; }
  39. virtual int GetWeaponProjectileType( void ) const OVERRIDE { return TF_PROJECTILE_GRAPPLINGHOOK; }
  40. virtual bool ShouldRemoveDisguiseOnPrimaryAttack() const OVERRIDE { return false; }
  41. virtual bool ShouldRemoveInvisibilityOnPrimaryAttack() const OVERRIDE { return false; }
  42. virtual int GetCanAttackFlags() const OVERRIDE { return TF_CAN_ATTACK_FLAG_GRAPPLINGHOOK; }
  43. virtual bool SendWeaponAnim( int iActivity );
  44. virtual void PlayWeaponShootSound( void ) OVERRIDE;
  45. #ifdef CLIENT_DLL
  46. virtual void UpdateOnRemove() OVERRIDE;
  47. virtual void OnDataChanged( DataUpdateType_t type ) OVERRIDE;
  48. #endif // CLIENT_DLL
  49. // acttable override
  50. virtual acttable_t *ActivityList( int &iActivityCount ) OVERRIDE;
  51. // poseparam override
  52. virtual poseparamtable_t *PoseParamList( int &iPoseParamCount ) OVERRIDE;
  53. #ifdef GAME_DLL
  54. void ActivateRune();
  55. #endif // GAME_DLL
  56. private:
  57. #ifdef GAME_DLL
  58. void RemoveHookProjectile( bool bForce = false );
  59. bool IsLatchedToTargetPlayer() const;
  60. bool m_bReleasedAfterLatched;
  61. #endif // GAME_DLL
  62. #ifdef CLIENT_DLL
  63. void StartHookSound();
  64. void StopHookSound();
  65. void UpdateHookSound();
  66. CSoundPatch *m_pHookSound;
  67. bool m_bLatched;
  68. float m_flNextSupernovaDenyWarning;
  69. #endif // CLIENT_DLL
  70. void OnHookReleased( bool bForce );
  71. CNetworkHandle( CBaseEntity, m_hProjectile );
  72. CountdownTimer m_startFiringTimer;
  73. CountdownTimer m_startPullingTimer;
  74. };
  75. #ifdef CLIENT_DLL
  76. class CEquipGrapplingHookNotification : public CEconNotification
  77. {
  78. public:
  79. CEquipGrapplingHookNotification() : CEconNotification()
  80. {
  81. m_bHasTriggered = false;
  82. }
  83. ~CEquipGrapplingHookNotification()
  84. {
  85. if ( !m_bHasTriggered )
  86. {
  87. m_bHasTriggered = true;
  88. }
  89. }
  90. virtual void MarkForDeletion()
  91. {
  92. m_bHasTriggered = true;
  93. CEconNotification::MarkForDeletion();
  94. }
  95. virtual bool BShowInGameElements() const { return true; }
  96. virtual EType NotificationType() { return eType_AcceptDecline; }
  97. virtual void Accept();
  98. virtual void Trigger() { Accept(); }
  99. virtual void Decline() { MarkForDeletion(); }
  100. virtual void UpdateTick();
  101. static bool IsNotificationType( CEconNotification *pNotification ) { return dynamic_cast< CEquipGrapplingHookNotification *>( pNotification ) != NULL; }
  102. private:
  103. bool m_bHasTriggered;
  104. };
  105. #endif // CLIENT_DLL
  106. #endif // TF_WEAPON_GRAPPLINGHOOK_H