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

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "fx_trail.h"
  8. C_ParticleTrail::C_ParticleTrail( void )
  9. {
  10. }
  11. C_ParticleTrail::~C_ParticleTrail( void )
  12. {
  13. if ( m_pParticleMgr )
  14. {
  15. m_pParticleMgr->RemoveEffect( &m_ParticleEffect );
  16. }
  17. }
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Gets the attachment point to spawn at
  20. //-----------------------------------------------------------------------------
  21. void C_ParticleTrail::GetAimEntOrigin( IClientEntity *pAttachedTo, Vector *pAbsOrigin, QAngle *pAbsAngles )
  22. {
  23. C_BaseEntity *pEnt = pAttachedTo->GetBaseEntity();
  24. if ( pEnt && (m_nAttachment > 0) )
  25. {
  26. pEnt->GetAttachment( m_nAttachment, *pAbsOrigin, *pAbsAngles );
  27. return;
  28. }
  29. BaseClass::GetAimEntOrigin( pAttachedTo, pAbsOrigin, pAbsAngles );
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Turn on the emission of particles
  33. //-----------------------------------------------------------------------------
  34. void C_ParticleTrail::SetEmit( bool bEmit )
  35. {
  36. m_bEmit = bEmit;
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose: Set the spawn rate of the effect
  40. //-----------------------------------------------------------------------------
  41. void C_ParticleTrail::SetSpawnRate( float rate )
  42. {
  43. m_SpawnRate = rate;
  44. m_ParticleSpawn.Init( rate );
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose: First sent down from the server
  48. //-----------------------------------------------------------------------------
  49. void C_ParticleTrail::OnDataChanged(DataUpdateType_t updateType)
  50. {
  51. C_BaseEntity::OnDataChanged(updateType);
  52. if ( updateType == DATA_UPDATE_CREATED )
  53. {
  54. Start( ParticleMgr(), NULL );
  55. }
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. //-----------------------------------------------------------------------------
  60. void C_ParticleTrail::Start( CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs )
  61. {
  62. if( pParticleMgr->AddEffect( &m_ParticleEffect, this ) == false )
  63. return;
  64. m_pParticleMgr = pParticleMgr;
  65. }