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.

101 lines
3.3 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. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //-----------------------------------------------------------------------------
  14. // Purpose: create clientside physics prop, as breaks model if needed
  15. //-----------------------------------------------------------------------------
  16. class CTEPhysicsProp : public CBaseTempEntity
  17. {
  18. public:
  19. DECLARE_CLASS( CTEPhysicsProp, CBaseTempEntity );
  20. CTEPhysicsProp( const char *name );
  21. virtual ~CTEPhysicsProp( void );
  22. DECLARE_SERVERCLASS();
  23. public:
  24. CNetworkVector( m_vecOrigin );
  25. CNetworkQAngle( m_angRotation );
  26. CNetworkVector( m_vecVelocity );
  27. CNetworkVar( int, m_nModelIndex );
  28. CNetworkVar( int, m_nSkin );
  29. CNetworkVar( int, m_nFlags );
  30. CNetworkVar( int, m_nEffects );
  31. CNetworkColor32( m_clrRender );
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Purpose:
  35. // Input : *name -
  36. //-----------------------------------------------------------------------------
  37. CTEPhysicsProp::CTEPhysicsProp( const char *name ) :
  38. CBaseTempEntity( name )
  39. {
  40. color32 white = {255, 255, 255, 255};
  41. m_vecOrigin.Init();
  42. m_angRotation.Init();
  43. m_vecVelocity.Init();
  44. m_nModelIndex = 0;
  45. m_nSkin = 0;
  46. m_nFlags = 0;
  47. m_nEffects = 0;
  48. m_clrRender = white;
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. //-----------------------------------------------------------------------------
  53. CTEPhysicsProp::~CTEPhysicsProp( void )
  54. {
  55. }
  56. IMPLEMENT_SERVERCLASS_ST(CTEPhysicsProp, DT_TEPhysicsProp)
  57. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  58. SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 0), 13 ),
  59. SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 1), 13 ),
  60. SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 2), 13 ),
  61. SendPropVector( SENDINFO(m_vecVelocity), -1, SPROP_COORD),
  62. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  63. SendPropInt( SENDINFO(m_nSkin), ANIMATION_SKIN_BITS),
  64. SendPropInt( SENDINFO(m_nFlags), 2, SPROP_UNSIGNED ),
  65. SendPropInt( SENDINFO(m_nEffects), EF_MAX_BITS, SPROP_UNSIGNED),
  66. SendPropInt( SENDINFO(m_clrRender), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
  67. END_SEND_TABLE()
  68. // Singleton to fire TEBreakModel objects
  69. static CTEPhysicsProp s_TEPhysicsProp( "physicsprop" );
  70. void TE_PhysicsProp( IRecipientFilter& filter, float delay,
  71. int modelindex, int skin, const Vector& pos, const QAngle &angles, const Vector& vel, int flags, int effects, color24 renderColor )
  72. {
  73. color32 clrRenderConverted;
  74. clrRenderConverted.r = renderColor.r;
  75. clrRenderConverted.g = renderColor.g;
  76. clrRenderConverted.b = renderColor.b;
  77. clrRenderConverted.a = 255;
  78. s_TEPhysicsProp.m_vecOrigin = pos;
  79. s_TEPhysicsProp.m_angRotation = angles;
  80. s_TEPhysicsProp.m_vecVelocity = vel;
  81. s_TEPhysicsProp.m_nModelIndex = modelindex;
  82. s_TEPhysicsProp.m_nSkin = skin;
  83. s_TEPhysicsProp.m_nFlags = flags;
  84. s_TEPhysicsProp.m_nEffects = effects;
  85. s_TEPhysicsProp.m_clrRender = clrRenderConverted;
  86. // Send it over the wire
  87. s_TEPhysicsProp.Create( filter, delay );
  88. }