Counter Strike : Global Offensive Source Code
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.

73 lines
2.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "particles_attractor.h"
  8. #include "tier0/memdbgon.h"
  9. //-----------------------------------------------------------------------------
  10. // Purpose:
  11. // Input : &center -
  12. // "attractor" -
  13. // Output : CParticleAttractor
  14. //-----------------------------------------------------------------------------
  15. CParticleAttractor *CParticleAttractor::Create( const Vector &center, const char *pDebugName )
  16. {
  17. CParticleAttractor *pSystem = new CParticleAttractor( pDebugName );
  18. pSystem->SetAttractorOrigin( center );
  19. return pSystem;
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose:
  23. // Input : *pParticle -
  24. // timeDelta -
  25. //-----------------------------------------------------------------------------
  26. void CParticleAttractor::UpdateVelocity( SimpleParticle *pParticle, float timeDelta )
  27. {
  28. float speed = VectorNormalize( pParticle->m_vecVelocity );
  29. Vector offset;
  30. Vector dir = ( m_vecAttractorOrigin - pParticle->m_Pos );
  31. VectorNormalize( dir );
  32. speed = clamp( (speed+speed*0.2f), 0, 1024 );
  33. pParticle->m_vecVelocity += dir * speed;
  34. }
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. // Input : *pParticle -
  38. // timeDelta -
  39. // Output : float
  40. //-----------------------------------------------------------------------------
  41. float CParticleAttractor::UpdateScale( const SimpleParticle *pParticle )
  42. {
  43. return ( ((float)pParticle->m_uchStartSize) * sin( M_PI * (pParticle->m_flLifetime / pParticle->m_flDieTime) ) );
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. // Input : *pParticle -
  48. // timeDelta -
  49. // Output : float
  50. //-----------------------------------------------------------------------------
  51. float CParticleAttractor::UpdateAlpha( const SimpleParticle *pParticle )
  52. {
  53. return ( ((float)pParticle->m_uchStartAlpha/255.0f) * sin( M_PI * (pParticle->m_flLifetime / pParticle->m_flDieTime) ) );
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. // Input : &origin -
  58. //-----------------------------------------------------------------------------
  59. void CParticleAttractor::SetAttractorOrigin( const Vector &origin )
  60. {
  61. m_vecAttractorOrigin = origin;
  62. }