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.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "c_dod_basegrenade.h"
  8. #include "c_dod_player.h"
  9. #include "dodoverview.h"
  10. IMPLEMENT_NETWORKCLASS_ALIASED( DODBaseGrenade, DT_DODBaseGrenade )
  11. BEGIN_NETWORK_TABLE(C_DODBaseGrenade, DT_DODBaseGrenade )
  12. RecvPropVector( RECVINFO( m_vInitialVelocity ) )
  13. END_NETWORK_TABLE()
  14. //-----------------------------------------------------------------------------
  15. // Purpose:
  16. //-----------------------------------------------------------------------------
  17. C_DODBaseGrenade::~C_DODBaseGrenade()
  18. {
  19. GetDODOverview()->RemoveGrenade( this );
  20. ParticleProp()->StopEmission();
  21. }
  22. void C_DODBaseGrenade::PostDataUpdate( DataUpdateType_t type )
  23. {
  24. BaseClass::PostDataUpdate( type );
  25. if ( type == DATA_UPDATE_CREATED )
  26. {
  27. // Now stick our initial velocity into the interpolation history
  28. CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator();
  29. interpolator.ClearHistory();
  30. float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR );
  31. // Add a sample 1 second back.
  32. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity;
  33. interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false );
  34. // Add the current sample.
  35. vCurOrigin = GetLocalOrigin();
  36. interpolator.AddToHead( changeTime, &vCurOrigin, false );
  37. // BUG ? this may call multiple times
  38. GetDODOverview()->AddGrenade( this );
  39. const char *pszParticleTrail = GetParticleTrailName();
  40. if ( pszParticleTrail )
  41. {
  42. ParticleProp()->Create( pszParticleTrail, PATTACH_ABSORIGIN_FOLLOW );
  43. }
  44. }
  45. }
  46. int C_DODBaseGrenade::DrawModel( int flags )
  47. {
  48. if( m_flSpawnTime + 0.15 > gpGlobals->curtime )
  49. return 0;
  50. C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
  51. if ( pPlayer && GetAbsVelocity().Length() < 30 )
  52. {
  53. pPlayer->CheckGrenadeHint( GetAbsOrigin() );
  54. }
  55. return BaseClass::DrawModel( flags );
  56. }
  57. void C_DODBaseGrenade::Spawn()
  58. {
  59. m_flSpawnTime = gpGlobals->curtime;
  60. BaseClass::Spawn();
  61. }
  62. const char *C_DODBaseGrenade::GetOverviewSpriteName( void )
  63. {
  64. const char *pszSprite = "";
  65. switch( GetTeamNumber() )
  66. {
  67. case TEAM_ALLIES:
  68. pszSprite = "sprites/minimap_icons/grenade_hltv";
  69. break;
  70. case TEAM_AXIS:
  71. pszSprite = "sprites/minimap_icons/stick_hltv";
  72. break;
  73. default:
  74. break;
  75. }
  76. return pszSprite;
  77. }
  78. IMPLEMENT_NETWORKCLASS_ALIASED( DODRifleGrenadeUS, DT_DODRifleGrenadeUS )
  79. BEGIN_NETWORK_TABLE(C_DODRifleGrenadeUS, DT_DODRifleGrenadeUS )
  80. END_NETWORK_TABLE()
  81. IMPLEMENT_CLIENTCLASS_DT(C_DODRifleGrenadeGER, DT_DODRifleGrenadeGER, CDODRifleGrenadeGER)
  82. END_RECV_TABLE()