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.

147 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Game-specific explosion effects
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "c_te_effect_dispatch.h"
  8. #include "tempent.h"
  9. #include "c_te_legacytempents.h"
  10. #include "tf_shareddefs.h"
  11. #include "c_basetempentity.h"
  12. #include "tier0/vprof.h"
  13. #include "c_tf_fx.h"
  14. //-----------------------------------------------------------------------------
  15. // Purpose:
  16. //-----------------------------------------------------------------------------
  17. class C_TETFParticleEffect : public C_BaseTempEntity
  18. {
  19. public:
  20. DECLARE_CLASS( C_TETFParticleEffect, C_BaseTempEntity );
  21. DECLARE_CLIENTCLASS();
  22. C_TETFParticleEffect( void );
  23. virtual void PostDataUpdate( DataUpdateType_t updateType );
  24. public:
  25. Vector m_vecOrigin;
  26. Vector m_vecStart;
  27. QAngle m_vecAngles;
  28. int m_iParticleSystemIndex;
  29. ClientEntityHandle_t m_hEntity;
  30. int m_iAttachType;
  31. int m_iAttachmentPointIndex;
  32. bool m_bResetParticles;
  33. bool m_bCustomColors;
  34. te_tf_particle_effects_colors_t m_CustomColors;
  35. bool m_bControlPoint1;
  36. te_tf_particle_effects_control_point_t m_ControlPoint1;
  37. };
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. C_TETFParticleEffect::C_TETFParticleEffect( void )
  42. {
  43. m_vecOrigin.Init();
  44. m_vecStart.Init();
  45. m_vecAngles.Init();
  46. m_iParticleSystemIndex = -1;
  47. m_hEntity = INVALID_EHANDLE_INDEX;
  48. m_iAttachType = PATTACH_ABSORIGIN;
  49. m_iAttachmentPointIndex = 0;
  50. m_bResetParticles = false;
  51. m_bCustomColors = false;
  52. m_CustomColors.m_vecColor1.Init();
  53. m_CustomColors.m_vecColor2.Init();
  54. m_bControlPoint1 = false;
  55. m_ControlPoint1.m_eParticleAttachment = PATTACH_ABSORIGIN;
  56. m_ControlPoint1.m_vecOffset.Init();
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Purpose:
  60. //-----------------------------------------------------------------------------
  61. void C_TETFParticleEffect::PostDataUpdate( DataUpdateType_t updateType )
  62. {
  63. VPROF( "C_TETFParticleEffect::PostDataUpdate" );
  64. CEffectData data;
  65. data.m_nHitBox = m_iParticleSystemIndex;
  66. data.m_vOrigin = m_vecOrigin;
  67. data.m_vStart = m_vecStart;
  68. data.m_vAngles = m_vecAngles;
  69. if ( m_hEntity != INVALID_EHANDLE_INDEX )
  70. {
  71. data.m_hEntity = m_hEntity;
  72. data.m_fFlags |= PARTICLE_DISPATCH_FROM_ENTITY;
  73. }
  74. else
  75. {
  76. data.m_hEntity = NULL;
  77. }
  78. data.m_nDamageType = m_iAttachType;
  79. data.m_nAttachmentIndex = m_iAttachmentPointIndex;
  80. if ( m_bResetParticles )
  81. {
  82. data.m_fFlags |= PARTICLE_DISPATCH_RESET_PARTICLES;
  83. }
  84. data.m_bCustomColors = m_bCustomColors;
  85. data.m_CustomColors = m_CustomColors;
  86. data.m_bControlPoint1 = m_bControlPoint1;
  87. data.m_ControlPoint1 = m_ControlPoint1;
  88. DispatchEffect( "ParticleEffect", data );
  89. }
  90. static void RecvProxy_ParticleSystemEntIndex( const CRecvProxyData *pData, void *pStruct, void *pOut )
  91. {
  92. int nEntIndex = pData->m_Value.m_Int;
  93. // The 'new' encoding for INVALID_EHANDLE_INDEX is 2047, but the old encoding
  94. // was -1. Old demos and replays will use the old encoding so we have to check
  95. // for it. The field is now unsigned so -1 will not be created in new replays.
  96. ((C_TETFParticleEffect*)pStruct)->m_hEntity = (nEntIndex == kInvalidEHandleParticleEffect || nEntIndex == -1) ? INVALID_EHANDLE_INDEX : ClientEntityList().EntIndexToHandle( nEntIndex );
  97. }
  98. IMPLEMENT_CLIENTCLASS_EVENT_DT( C_TETFParticleEffect, DT_TETFParticleEffect, CTETFParticleEffect )
  99. RecvPropFloat( RECVINFO( m_vecOrigin[0] ) ),
  100. RecvPropFloat( RECVINFO( m_vecOrigin[1] ) ),
  101. RecvPropFloat( RECVINFO( m_vecOrigin[2] ) ),
  102. RecvPropFloat( RECVINFO( m_vecStart[0] ) ),
  103. RecvPropFloat( RECVINFO( m_vecStart[1] ) ),
  104. RecvPropFloat( RECVINFO( m_vecStart[2] ) ),
  105. RecvPropQAngles( RECVINFO( m_vecAngles ) ),
  106. RecvPropInt( RECVINFO( m_iParticleSystemIndex ) ),
  107. RecvPropInt( "entindex", 0, SIZEOF_IGNORE, 0, RecvProxy_ParticleSystemEntIndex ),
  108. RecvPropInt( RECVINFO( m_iAttachType ) ),
  109. RecvPropInt( RECVINFO( m_iAttachmentPointIndex ) ),
  110. RecvPropInt( RECVINFO( m_bResetParticles ) ),
  111. RecvPropBool( RECVINFO( m_bCustomColors ) ),
  112. RecvPropVector( RECVINFO( m_CustomColors.m_vecColor1 ) ),
  113. RecvPropVector( RECVINFO( m_CustomColors.m_vecColor2 ) ),
  114. RecvPropBool( RECVINFO( m_bControlPoint1 ) ),
  115. RecvPropInt( RECVINFO( m_ControlPoint1.m_eParticleAttachment ) ),
  116. RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[0] ) ),
  117. RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[1] ) ),
  118. RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[2] ) ),
  119. END_RECV_TABLE()