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.

106 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef DOD_BASEGRENADE_H
  7. #define DOD_BASEGRENADE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "weapon_dodbase.h"
  12. #include "basegrenade_shared.h"
  13. class CGrenadeTrail;
  14. class CGrenadeController : public IMotionEvent
  15. {
  16. DECLARE_SIMPLE_DATADESC();
  17. public:
  18. virtual simresult_e Simulate( IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular );
  19. };
  20. class CDODBaseGrenade : public CBaseGrenade
  21. {
  22. public:
  23. DECLARE_CLASS( CDODBaseGrenade, CBaseGrenade );
  24. DECLARE_DATADESC();
  25. DECLARE_SERVERCLASS();
  26. CDODBaseGrenade();
  27. virtual ~CDODBaseGrenade();
  28. virtual void Spawn();
  29. virtual void Precache( void );
  30. static inline float GetGrenadeGravity() { return 0.4f; }
  31. static inline const float GetGrenadeFriction() { return 0.5f; }
  32. static inline const float GetGrenadeElasticity() { return 0.2f; }
  33. void DetonateThink( void );
  34. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  35. virtual char *GetExplodingClassname( void );
  36. virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_USE_IN_RADIUS; }
  37. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  38. virtual void Detonate();
  39. bool CreateVPhysics();
  40. virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
  41. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );
  42. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  43. void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity )
  44. {
  45. m_vInitialVelocity = velocity;
  46. }
  47. CGrenadeController m_GrenadeController;
  48. IPhysicsMotionController *m_pMotionController;
  49. virtual bool CanBePickedUp( void ) { return true; }
  50. virtual void OnPickedUp( void ) {}
  51. virtual float GetElasticity();
  52. virtual DODWeaponID GetEmitterWeaponID() { return m_EmitterWeaponID; }
  53. protected:
  54. //Set the time to detonate ( now + timer )
  55. virtual void SetDetonateTimerLength( float timer );
  56. float m_flDetonateTime;
  57. //Custom collision to allow for constant elasticity on hit surfaces
  58. virtual void ResolveFlyCollisionCustom( trace_t &trace, Vector &vecVelocity );
  59. bool m_bUseVPhysics;
  60. DODWeaponID m_EmitterWeaponID;
  61. private:
  62. CDODBaseGrenade( const CDODBaseGrenade & );
  63. bool m_bInSolid;
  64. // This gets sent to the client and placed in the client's interpolation history
  65. // so the projectile starts out moving right off the bat.
  66. CNetworkVector( m_vInitialVelocity );
  67. float m_flCollideWithTeammatesTime;
  68. bool m_bCollideWithTeammates;
  69. };
  70. #endif // DOD_BASEGRENADE_H