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.

115 lines
2.7 KiB

  1. //===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "cbase.h"
  9. #include "baseparticleentity.h"
  10. #ifdef CLIENT_DLL
  11. #include "tier1/keyvalues.h"
  12. #include "toolframework_client.h"
  13. #endif
  14. // memdbgon must be the last include file in a .cpp file!!!
  15. #include "tier0/memdbgon.h"
  16. IMPLEMENT_NETWORKCLASS_ALIASED( BaseParticleEntity, DT_BaseParticleEntity )
  17. BEGIN_NETWORK_TABLE( CBaseParticleEntity, DT_BaseParticleEntity )
  18. END_NETWORK_TABLE()
  19. BEGIN_PREDICTION_DATA( CBaseParticleEntity )
  20. END_PREDICTION_DATA()
  21. #ifdef CLIENT_DLL
  22. REGISTER_EFFECT( CBaseParticleEntity );
  23. #endif
  24. CBaseParticleEntity::CBaseParticleEntity( void )
  25. {
  26. #if defined( CLIENT_DLL )
  27. m_bSimulate = true;
  28. m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID;
  29. #endif
  30. }
  31. CBaseParticleEntity::~CBaseParticleEntity( void )
  32. {
  33. #if defined( CLIENT_DLL )
  34. if ( ToolsEnabled() && ( m_nToolParticleEffectId != TOOLPARTICLESYSTEMID_INVALID ) && clienttools->IsInRecordingMode() )
  35. {
  36. KeyValues *msg = new KeyValues( "OldParticleSystem_Destroy" );
  37. msg->SetInt( "id", m_nToolParticleEffectId );
  38. m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID;
  39. }
  40. #endif
  41. }
  42. #if !defined( CLIENT_DLL )
  43. int CBaseParticleEntity::UpdateTransmitState( void )
  44. {
  45. if ( IsEffectActive( EF_NODRAW ) )
  46. return SetTransmitState( FL_EDICT_DONTSEND );
  47. if ( IsEFlagSet( EFL_IN_SKYBOX ) )
  48. return SetTransmitState( FL_EDICT_ALWAYS );
  49. // cull against PVS
  50. return SetTransmitState( FL_EDICT_PVSCHECK );
  51. }
  52. #endif
  53. void CBaseParticleEntity::Activate()
  54. {
  55. #if !defined( CLIENT_DLL )
  56. BaseClass::Activate();
  57. #endif
  58. }
  59. void CBaseParticleEntity::Think()
  60. {
  61. Remove( );
  62. }
  63. void CBaseParticleEntity::FollowEntity(CBaseEntity *pEntity)
  64. {
  65. BaseClass::FollowEntity( pEntity );
  66. SetLocalOrigin( vec3_origin );
  67. }
  68. void CBaseParticleEntity::SetLifetime(float lifetime)
  69. {
  70. if(lifetime == -1)
  71. SetNextThink( TICK_NEVER_THINK );
  72. else
  73. SetNextThink( gpGlobals->curtime + lifetime );
  74. }
  75. #if defined( CLIENT_DLL )
  76. const Vector &CBaseParticleEntity::GetSortOrigin()
  77. {
  78. // By default, we do the cheaper behavior of getting the root parent's abs origin, so we don't have to
  79. // setup any bones along the way. If this screws anything up, we can always make it an option.
  80. return GetRootMoveParent()->GetAbsOrigin();
  81. }
  82. void CBaseParticleEntity::SimulateParticles( CParticleSimulateIterator *pIterator )
  83. {
  84. // If you derive from CBaseParticleEntity, you must implement simulation and rendering.
  85. Assert( false );
  86. }
  87. void CBaseParticleEntity::RenderParticles( CParticleRenderIterator *pIterator )
  88. {
  89. // If you derive from CBaseParticleEntity, you must implement simulation and rendering.
  90. Assert( false );
  91. }
  92. #endif