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.

111 lines
3.2 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //===========================================================================//
  9. #include "cbase.h"
  10. #include "c_basetempentity.h"
  11. #include "IEffects.h"
  12. #include "tier1/keyvalues.h"
  13. #include "toolframework_client.h"
  14. #include "tier0/vprof.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Smoke TE
  19. //-----------------------------------------------------------------------------
  20. class C_TESmoke : public C_BaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( C_TESmoke, C_BaseTempEntity );
  24. DECLARE_CLIENTCLASS();
  25. C_TESmoke( void );
  26. virtual ~C_TESmoke( void );
  27. virtual void PostDataUpdate( DataUpdateType_t updateType );
  28. public:
  29. Vector m_vecOrigin;
  30. int m_nModelIndex;
  31. float m_fScale;
  32. int m_nFrameRate;
  33. };
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. //-----------------------------------------------------------------------------
  37. C_TESmoke::C_TESmoke( void )
  38. {
  39. m_vecOrigin.Init();
  40. m_nModelIndex = 0;
  41. m_fScale = 0;
  42. m_nFrameRate = 0;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. C_TESmoke::~C_TESmoke( void )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Recording
  52. //-----------------------------------------------------------------------------
  53. static inline void RecordSmoke( const Vector &start, float flScale, int nFrameRate )
  54. {
  55. if ( !ToolsEnabled() )
  56. return;
  57. if ( clienttools->IsInRecordingMode() )
  58. {
  59. KeyValues *msg = new KeyValues( "TempEntity" );
  60. msg->SetInt( "te", TE_SMOKE );
  61. msg->SetString( "name", "TE_Smoke" );
  62. msg->SetFloat( "time", gpGlobals->curtime );
  63. msg->SetFloat( "originx", start.x );
  64. msg->SetFloat( "originy", start.y );
  65. msg->SetFloat( "originz", start.z );
  66. msg->SetFloat( "scale", flScale );
  67. msg->SetInt( "framerate", nFrameRate );
  68. ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
  69. msg->deleteThis();
  70. }
  71. }
  72. //-----------------------------------------------------------------------------
  73. // Purpose:
  74. //-----------------------------------------------------------------------------
  75. void C_TESmoke::PostDataUpdate( DataUpdateType_t updateType )
  76. {
  77. VPROF( "C_TESmoke::PostDataUpdate" );
  78. // The number passed down is 10 times smaller...
  79. g_pEffects->Smoke( m_vecOrigin, m_nModelIndex, m_fScale * 10.0f, m_nFrameRate );
  80. RecordSmoke( m_vecOrigin, m_fScale * 10.0f, m_nFrameRate );
  81. }
  82. void TE_Smoke( IRecipientFilter& filter, float delay,
  83. const Vector* pos, int modelindex, float scale, int framerate )
  84. {
  85. // The number passed down is 10 times smaller...
  86. g_pEffects->Smoke( *pos, modelindex, scale * 10.0f, framerate );
  87. RecordSmoke( *pos, scale * 10.0f, framerate );
  88. }
  89. IMPLEMENT_CLIENTCLASS_EVENT_DT(C_TESmoke, DT_TESmoke, CTESmoke)
  90. RecvPropVector( RECVINFO(m_vecOrigin)),
  91. RecvPropInt( RECVINFO(m_nModelIndex)),
  92. RecvPropFloat( RECVINFO(m_fScale )),
  93. RecvPropInt( RECVINFO(m_nFrameRate)),
  94. END_RECV_TABLE()