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.

109 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "c_baseanimating.h"
  8. class C_DODBaseRocket : public C_BaseAnimating
  9. {
  10. public:
  11. DECLARE_CLASS( C_DODBaseRocket, C_BaseAnimating );
  12. DECLARE_CLIENTCLASS();
  13. C_DODBaseRocket();
  14. virtual ~C_DODBaseRocket();
  15. virtual void Spawn();
  16. virtual int DrawModel( int flags );
  17. virtual void PostDataUpdate( DataUpdateType_t type );
  18. private:
  19. CNetworkVector( m_vInitialVelocity );
  20. float m_flSpawnTime;
  21. };
  22. IMPLEMENT_CLIENTCLASS_DT(C_DODBaseRocket, DT_DODBaseRocket, CDODBaseRocket)
  23. RecvPropVector( RECVINFO( m_vInitialVelocity ) )
  24. END_RECV_TABLE()
  25. //-----------------------------------------------------------------------------
  26. // Purpose:
  27. //-----------------------------------------------------------------------------
  28. C_DODBaseRocket::C_DODBaseRocket()
  29. {
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. //-----------------------------------------------------------------------------
  34. C_DODBaseRocket::~C_DODBaseRocket()
  35. {
  36. ParticleProp()->StopEmission();
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. void C_DODBaseRocket::Spawn()
  42. {
  43. m_flSpawnTime = gpGlobals->curtime;
  44. BaseClass::Spawn();
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose:
  48. //-----------------------------------------------------------------------------
  49. void C_DODBaseRocket::PostDataUpdate( DataUpdateType_t type )
  50. {
  51. BaseClass::PostDataUpdate( type );
  52. if ( type == DATA_UPDATE_CREATED )
  53. {
  54. // Now stick our initial velocity into the interpolation history
  55. CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator();
  56. interpolator.ClearHistory();
  57. float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR );
  58. // Add a sample 1 second back.
  59. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity;
  60. interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false );
  61. // Add the current sample.
  62. vCurOrigin = GetLocalOrigin();
  63. interpolator.AddToHead( changeTime, &vCurOrigin, false );
  64. // do the same for angles
  65. CInterpolatedVar< QAngle > &rotInterpolator = GetRotationInterpolator();
  66. rotInterpolator.ClearHistory();
  67. // Add a rotation sample 1 second back
  68. QAngle vCurAngles = GetLocalAngles();
  69. rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false );
  70. // Add the current rotation
  71. rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false );
  72. int iAttachment = 1; //LookupAttachment( "smoke" ); // don't do bone access at this time, we know it's 1.
  73. ParticleProp()->Create( "rockettrail", PATTACH_POINT_FOLLOW, iAttachment );
  74. }
  75. }
  76. //-----------------------------------------------------------------------------
  77. // Purpose:
  78. //-----------------------------------------------------------------------------
  79. int C_DODBaseRocket::DrawModel( int flags )
  80. {
  81. // During the first half-second of our life, don't draw ourselves
  82. if ( gpGlobals->curtime - m_flSpawnTime < 0.2 )
  83. {
  84. return 0;
  85. }
  86. return BaseClass::DrawModel( flags );
  87. }