Counter Strike : Global Offensive Source Code
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.

115 lines
3.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef WEAPON_BASECSGRENADE_H
  7. #define WEAPON_BASECSGRENADE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "weapon_csbase.h"
  12. #include "cs_shareddefs.h"
  13. #ifdef CLIENT_DLL
  14. #define CBaseCSGrenade C_BaseCSGrenade
  15. #endif
  16. #ifdef GRENADE_UNDERHAND_FEATURE_ENABLED
  17. #define GRENADE_UNDERHAND_THRESHOLD 0.33f
  18. #endif
  19. class CBaseCSGrenade : public CWeaponCSBase
  20. {
  21. public:
  22. DECLARE_CLASS( CBaseCSGrenade, CWeaponCSBase );
  23. DECLARE_NETWORKCLASS();
  24. DECLARE_PREDICTABLE();
  25. CBaseCSGrenade();
  26. virtual void Precache();
  27. bool Deploy();
  28. bool Holster( CBaseCombatWeapon *pSwitchingTo );
  29. void PrimaryAttack();
  30. void SecondaryAttack();
  31. bool Reload();
  32. virtual void ItemPostFrame();
  33. virtual void ItemPreFrame();
  34. virtual void OnPickedUp( CBaseCombatCharacter *pNewOwner );
  35. void DecrementAmmo( CBaseCombatCharacter *pOwner );
  36. virtual void StartGrenadeThrow();
  37. virtual void ThrowGrenade();
  38. virtual void DropGrenade();
  39. bool IsPinPulled() const;
  40. bool IsBeingThrown() const { return m_fThrowTime > 0; }
  41. bool IsLoopingSoundPlaying( void ) { return m_bLoopingSoundPlaying; }
  42. void SetLoopingSoundPlaying( bool bPlaying ) { m_bLoopingSoundPlaying = bPlaying; }
  43. // true if grenade has been thrown or dropped
  44. bool GetIsThrown( void ) { return !m_bIsHeldByPlayer; }
  45. #ifdef CLIENT_DLL
  46. virtual int DrawModel( int flags, const RenderableInstance_t &instance ) OVERRIDE;
  47. #endif
  48. #ifdef GRENADE_UNDERHAND_FEATURE_ENABLED
  49. bool IsThrownUnderhand( void ) { return (m_flThrowStrength <= GRENADE_UNDERHAND_THRESHOLD); }
  50. float GetThrownStrength( void ) { return m_flThrowStrength; }
  51. float ApproachThrownStrength( void );
  52. #endif
  53. #ifndef CLIENT_DLL
  54. bool HasEmittedProjectile( void ) const { return m_bHasEmittedProjectile; }
  55. bool m_bHasEmittedProjectile;
  56. #endif
  57. #ifndef CLIENT_DLL
  58. DECLARE_DATADESC();
  59. virtual bool AllowsAutoSwitchFrom( void ) const;
  60. int CapabilitiesGet();
  61. // Each derived grenade class implements this.
  62. virtual void EmitGrenade( Vector vecSrc, QAngle vecAngles, Vector vecVel, AngularImpulse angImpulse, CBasePlayer *pPlayer, const CCSWeaponInfo& weaponInfo );
  63. #endif
  64. protected:
  65. CNetworkVar( bool, m_bRedraw ); // Draw the weapon again after throwing a grenade
  66. CNetworkVar( bool, m_bIsHeldByPlayer ); // is true when held by player, false when it's been thrown or dropped
  67. CNetworkVar( bool, m_bPinPulled ); // Set to true when the pin has been pulled but the grenade hasn't been thrown yet.
  68. CNetworkVar( float, m_fThrowTime ); // the time at which the grenade will be thrown. If this value is 0 then the time hasn't been set yet.
  69. CNetworkVar( bool, m_bLoopingSoundPlaying ); // Set to true when the grenade is playing a looping sound
  70. #ifdef GRENADE_UNDERHAND_FEATURE_ENABLED
  71. CNetworkVar( float, m_flThrowStrength );
  72. #endif
  73. private:
  74. CBaseCSGrenade( const CBaseCSGrenade & ) {}
  75. #ifdef GRENADE_UNDERHAND_FEATURE_ENABLED
  76. float m_flThrowStrengthClientSmooth;
  77. #endif
  78. };
  79. inline bool CBaseCSGrenade::IsPinPulled() const
  80. {
  81. return m_bPinPulled;
  82. }
  83. #endif // WEAPON_BASECSGRENADE_H