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.

75 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "particle_smokegrenade.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. IMPLEMENT_SERVERCLASS_ST(ParticleSmokeGrenade, DT_ParticleSmokeGrenade)
  13. SendPropTime(SENDINFO(m_flSpawnTime) ),
  14. SendPropFloat(SENDINFO(m_FadeStartTime), 0, SPROP_NOSCALE),
  15. SendPropFloat(SENDINFO(m_FadeEndTime), 0, SPROP_NOSCALE),
  16. SendPropInt(SENDINFO(m_CurrentStage), 1, SPROP_UNSIGNED),
  17. END_SEND_TABLE()
  18. LINK_ENTITY_TO_CLASS( env_particlesmokegrenade, ParticleSmokeGrenade );
  19. BEGIN_DATADESC( ParticleSmokeGrenade )
  20. DEFINE_FIELD( m_CurrentStage, FIELD_CHARACTER ),
  21. DEFINE_FIELD( m_FadeStartTime, FIELD_TIME ),
  22. DEFINE_FIELD( m_FadeEndTime, FIELD_TIME ),
  23. DEFINE_FIELD( m_flSpawnTime, FIELD_TIME ),
  24. END_DATADESC()
  25. ParticleSmokeGrenade::ParticleSmokeGrenade()
  26. {
  27. m_CurrentStage = 0;
  28. m_FadeStartTime = 17;
  29. m_FadeEndTime = 22;
  30. m_flSpawnTime = gpGlobals->curtime;
  31. }
  32. // Smoke grenade particles should always transmitted to clients. If not, a client who
  33. // enters the PVS late will see the smoke start billowing from then, allowing better vision.
  34. int ParticleSmokeGrenade::UpdateTransmitState( void )
  35. {
  36. if ( IsEffectActive( EF_NODRAW ) )
  37. return SetTransmitState( FL_EDICT_DONTSEND );
  38. return SetTransmitState( FL_EDICT_ALWAYS );
  39. }
  40. void ParticleSmokeGrenade::FillVolume()
  41. {
  42. m_CurrentStage = 1;
  43. CollisionProp()->SetCollisionBounds( Vector( -50, -50, -50 ), Vector( 50, 50, 50 ) );
  44. }
  45. void ParticleSmokeGrenade::SetFadeTime(float startTime, float endTime)
  46. {
  47. m_FadeStartTime = startTime;
  48. m_FadeEndTime = endTime;
  49. }
  50. // Fade start and end are relative to current time
  51. void ParticleSmokeGrenade::SetRelativeFadeTime(float startTime, float endTime)
  52. {
  53. float flCurrentTime = gpGlobals->curtime - m_flSpawnTime;
  54. m_FadeStartTime = flCurrentTime + startTime;
  55. m_FadeEndTime = flCurrentTime + endTime;
  56. }