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.

88 lines
2.3 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 CBaseCSGrenadeProjectile C_BaseCSGrenadeProjectile
  14. #else
  15. class CCSWeaponInfo;
  16. #endif
  17. class CBaseCSGrenadeProjectile : public CBaseGrenade
  18. {
  19. public:
  20. DECLARE_CLASS( CBaseCSGrenadeProjectile, CBaseGrenade );
  21. DECLARE_NETWORKCLASS();
  22. virtual void Spawn();
  23. public:
  24. // This gets sent to the client and placed in the client's interpolation history
  25. // so the projectile starts out moving right off the bat.
  26. CNetworkVector( m_vInitialVelocity );
  27. #ifdef CLIENT_DLL
  28. CBaseCSGrenadeProjectile() {}
  29. CBaseCSGrenadeProjectile( const CBaseCSGrenadeProjectile& ) {}
  30. virtual int DrawModel( int flags );
  31. virtual void PostDataUpdate( DataUpdateType_t type );
  32. float m_flSpawnTime;
  33. #else
  34. DECLARE_DATADESC();
  35. virtual void PostConstructor( const char *className );
  36. virtual ~CBaseCSGrenadeProjectile();
  37. //Constants for all CS Grenades
  38. static inline float GetGrenadeGravity() { return 0.4f; }
  39. static inline const float GetGrenadeFriction() { return 0.2f; }
  40. static inline const float GetGrenadeElasticity() { return 0.45f; }
  41. //Think function to emit danger sounds for the AI
  42. void DangerSoundThink( void );
  43. virtual float GetShakeAmplitude( void ) { return 0.0f; }
  44. virtual void Splash();
  45. // Specify what velocity we want the grenade to have on the client immediately.
  46. // Without this, the entity wouldn't have an interpolation history initially, so it would
  47. // sit still until it had gotten a few updates from the server.
  48. void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity );
  49. // [jpaquin] give grenade projectiles a link back to the type
  50. // of weapon they are
  51. CCSWeaponInfo *m_pWeaponInfo;
  52. protected:
  53. //Set the time to detonate ( now + timer )
  54. void SetDetonateTimerLength( float timer );
  55. private:
  56. //Custom collision to allow for constant elasticity on hit surfaces
  57. virtual void ResolveFlyCollisionCustom( trace_t &trace, Vector &vecVelocity );
  58. float m_flDetonateTime;
  59. #endif
  60. };
  61. #endif // BASECSGRENADE_PROJECTILE_H