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.

100 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 "basetempentity.h"
  11. #include "vstdlib/random.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Dispatches model smash pieces
  16. //-----------------------------------------------------------------------------
  17. class CTEBreakModel : public CBaseTempEntity
  18. {
  19. public:
  20. DECLARE_CLASS( CTEBreakModel, CBaseTempEntity );
  21. CTEBreakModel( const char *name );
  22. virtual ~CTEBreakModel( void );
  23. DECLARE_SERVERCLASS();
  24. public:
  25. CNetworkVector( m_vecOrigin );
  26. CNetworkVector( m_vecSize );
  27. CNetworkVector( m_vecVelocity );
  28. CNetworkQAngle( m_angRotation );
  29. CNetworkVar( int, m_nRandomization );
  30. CNetworkVar( int, m_nModelIndex );
  31. CNetworkVar( int, m_nCount );
  32. CNetworkVar( float, m_fTime );
  33. CNetworkVar( int, m_nFlags );
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. // Input : *name -
  38. //-----------------------------------------------------------------------------
  39. CTEBreakModel::CTEBreakModel( const char *name ) :
  40. CBaseTempEntity( name )
  41. {
  42. m_vecOrigin.Init();
  43. m_vecSize.Init();
  44. m_vecVelocity.Init();
  45. m_angRotation.Init();
  46. m_nModelIndex = 0;
  47. m_nRandomization = 0;
  48. m_nCount = 0;
  49. m_fTime = 0.0;
  50. m_nFlags = 0;
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. //-----------------------------------------------------------------------------
  55. CTEBreakModel::~CTEBreakModel( void )
  56. {
  57. }
  58. IMPLEMENT_SERVERCLASS_ST(CTEBreakModel, DT_TEBreakModel)
  59. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  60. SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 0), 13 ),
  61. SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 1), 13 ),
  62. SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 2), 13 ),
  63. SendPropVector( SENDINFO(m_vecSize), -1, SPROP_COORD),
  64. SendPropVector( SENDINFO(m_vecVelocity), -1, SPROP_COORD),
  65. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  66. SendPropInt( SENDINFO(m_nRandomization), 9, SPROP_UNSIGNED ),
  67. SendPropInt( SENDINFO(m_nCount), 8, SPROP_UNSIGNED ),
  68. SendPropFloat( SENDINFO(m_fTime), 10, 0, 0, 102.4 ),
  69. SendPropInt( SENDINFO(m_nFlags), 8, SPROP_UNSIGNED ),
  70. END_SEND_TABLE()
  71. // Singleton to fire TEBreakModel objects
  72. static CTEBreakModel g_TEBreakModel( "breakmodel" );
  73. void TE_BreakModel( IRecipientFilter& filter, float delay,
  74. const Vector& pos, const QAngle& angles, const Vector& size, const Vector& vel, int modelindex, int randomization,
  75. int count, float time, int flags )
  76. {
  77. g_TEBreakModel.m_vecOrigin = pos;
  78. g_TEBreakModel.m_angRotation = angles;
  79. g_TEBreakModel.m_vecSize = size;
  80. g_TEBreakModel.m_vecVelocity = vel;
  81. g_TEBreakModel.m_nModelIndex = modelindex;
  82. g_TEBreakModel.m_nRandomization = randomization;
  83. g_TEBreakModel.m_nCount = count;
  84. g_TEBreakModel.m_fTime = time;
  85. g_TEBreakModel.m_nFlags = flags;
  86. // Send it over the wire
  87. g_TEBreakModel.Create( filter, delay );
  88. }