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.

78 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef BASECSGRENADE_PROJECTILE_H
  7. #define BASECSGRENADE_PROJECTILE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "basegrenade_shared.h"
  12. #ifdef CLIENT_DLL
  13. #define CBaseGrenadeProjectile C_BaseGrenadeProjectile
  14. #endif
  15. class CBaseGrenadeProjectile : public CBaseGrenade
  16. {
  17. public:
  18. DECLARE_CLASS( CBaseGrenadeProjectile, CBaseGrenade );
  19. DECLARE_NETWORKCLASS();
  20. virtual void Spawn();
  21. public:
  22. // This gets sent to the client and placed in the client's interpolation history
  23. // so the projectile starts out moving right off the bat.
  24. CNetworkVector( m_vInitialVelocity );
  25. #ifdef CLIENT_DLL
  26. CBaseGrenadeProjectile() {}
  27. CBaseGrenadeProjectile( const CBaseGrenadeProjectile& ) {}
  28. virtual int DrawModel( int flags );
  29. virtual void PostDataUpdate( DataUpdateType_t type );
  30. float m_flSpawnTime;
  31. #else
  32. DECLARE_DATADESC();
  33. //Constants for all CS Grenades
  34. static inline float GetGrenadeGravity() { return 0.4f; }
  35. static inline const float GetGrenadeFriction() { return 0.2f; }
  36. static inline const float GetGrenadeElasticity() { return 0.45f; }
  37. //Think function to emit danger sounds for the AI
  38. void DangerSoundThink( void );
  39. virtual float GetShakeAmplitude( void ) { return 0.0f; }
  40. // Specify what velocity we want the grenade to have on the client immediately.
  41. // Without this, the entity wouldn't have an interpolation history initially, so it would
  42. // sit still until it had gotten a few updates from the server.
  43. void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity );
  44. protected:
  45. //Set the time to detonate ( now + timer )
  46. void SetDetonateTimerLength( float timer );
  47. private:
  48. //Custom collision to allow for constant elasticity on hit surfaces
  49. virtual void ResolveFlyCollisionCustom( trace_t &trace, Vector &vecVelocity );
  50. float m_flDetonateTime;
  51. #endif
  52. };
  53. #endif // BASECSGRENADE_PROJECTILE_H