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.

191 lines
4.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "fire_smoke.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //---------------------------------------------------------
  13. // Save/Restore
  14. //---------------------------------------------------------
  15. BEGIN_DATADESC( CBaseFire )
  16. DEFINE_FIELD( m_flStartScale, FIELD_FLOAT ),
  17. DEFINE_FIELD( m_flScale, FIELD_FLOAT ),
  18. DEFINE_FIELD( m_flScaleTime, FIELD_TIME ),
  19. DEFINE_FIELD( m_nFlags, FIELD_INTEGER ),
  20. END_DATADESC()
  21. //==================================================
  22. // CBaseFire
  23. //==================================================
  24. CBaseFire::CBaseFire( void )
  25. {
  26. m_flStartScale = 0.0f;
  27. m_flScale = 0.0f;
  28. m_flScaleTime = 0.0f;
  29. m_nFlags = bitsFIRE_NONE;
  30. }
  31. CBaseFire::~CBaseFire( void )
  32. {
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Purpose: Take the current scale of the flame and move it towards a destination
  36. // Input : size - destination size
  37. // time - time to scale across
  38. //-----------------------------------------------------------------------------
  39. void CBaseFire::Scale( float size, float time )
  40. {
  41. //Send to the client
  42. m_flScale = size;
  43. m_flScaleTime = time;
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose: Overloaded Scale() function to set size
  47. // Input : start - beginning sizek
  48. // size - destination size
  49. // time - time to scale across
  50. //-----------------------------------------------------------------------------
  51. void CBaseFire::Scale( float start, float size, float time )
  52. {
  53. //Send to the client
  54. m_flStartScale = start;
  55. m_flScale = size;
  56. m_flScaleTime = time;
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Purpose:
  60. // Input : state -
  61. //-----------------------------------------------------------------------------
  62. void CBaseFire::Enable( int state )
  63. {
  64. if ( state )
  65. {
  66. m_nFlags |= bitsFIRE_ACTIVE;
  67. }
  68. else
  69. {
  70. m_nFlags &= ~bitsFIRE_ACTIVE;
  71. }
  72. }
  73. //==================================================
  74. // CFireSmoke
  75. //==================================================
  76. //Link the entity
  77. LINK_ENTITY_TO_CLASS( _firesmoke, CFireSmoke );
  78. //Send datatable
  79. IMPLEMENT_SERVERCLASS_ST( CFireSmoke, DT_FireSmoke )
  80. SendPropFloat( SENDINFO( m_flStartScale ), 0, SPROP_NOSCALE),
  81. SendPropFloat( SENDINFO( m_flScale ), 0, SPROP_NOSCALE),
  82. SendPropFloat( SENDINFO( m_flScaleTime ), 0, SPROP_NOSCALE),
  83. SendPropInt( SENDINFO( m_nFlags ), 8, SPROP_UNSIGNED ),
  84. SendPropModelIndex( SENDINFO( m_nFlameModelIndex ) ),
  85. SendPropModelIndex( SENDINFO( m_nFlameFromAboveModelIndex ) ),
  86. END_SEND_TABLE()
  87. //Data description
  88. BEGIN_DATADESC( CFireSmoke )
  89. DEFINE_FIELD( m_flStartScale, FIELD_FLOAT ),
  90. DEFINE_FIELD( m_flScale, FIELD_FLOAT ),
  91. DEFINE_FIELD( m_flScaleTime, FIELD_FLOAT ),
  92. DEFINE_FIELD( m_nFlags, FIELD_INTEGER ),
  93. DEFINE_FIELD( m_nFlameModelIndex, FIELD_MODELINDEX ),
  94. DEFINE_FIELD( m_nFlameFromAboveModelIndex, FIELD_MODELINDEX ),
  95. END_DATADESC()
  96. //-----------------------------------------------------------------------------
  97. // Purpose:
  98. // Input : *name -
  99. //-----------------------------------------------------------------------------
  100. CFireSmoke::CFireSmoke( void )
  101. {
  102. //Client-side
  103. m_flScale = 0.0f;
  104. m_flScaleTime = 0.0f;
  105. m_nFlags = bitsFIRE_NONE;
  106. //Server-side
  107. AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
  108. }
  109. //-----------------------------------------------------------------------------
  110. // Purpose:
  111. //-----------------------------------------------------------------------------
  112. CFireSmoke::~CFireSmoke( void )
  113. {
  114. }
  115. //-----------------------------------------------------------------------------
  116. // Purpose:
  117. //-----------------------------------------------------------------------------
  118. void CFireSmoke::Precache()
  119. {
  120. BaseClass::Precache();
  121. }
  122. void CFireSmoke::Spawn()
  123. {
  124. Precache();
  125. }
  126. //-----------------------------------------------------------------------------
  127. // Purpose:
  128. // Input : state -
  129. //-----------------------------------------------------------------------------
  130. void CFireSmoke::EnableSmoke( int state )
  131. {
  132. if ( state )
  133. {
  134. m_nFlags |= bitsFIRESMOKE_SMOKE;
  135. }
  136. else
  137. {
  138. m_nFlags &= ~bitsFIRESMOKE_SMOKE;
  139. }
  140. }
  141. //-----------------------------------------------------------------------------
  142. // Purpose:
  143. // Input : state -
  144. //-----------------------------------------------------------------------------
  145. void CFireSmoke::EnableGlow( int state )
  146. {
  147. if ( state )
  148. {
  149. m_nFlags |= bitsFIRESMOKE_GLOW;
  150. }
  151. else
  152. {
  153. m_nFlags &= ~bitsFIRESMOKE_GLOW;
  154. }
  155. }
  156. void CFireSmoke::EnableVisibleFromAbove( int state )
  157. {
  158. if ( state )
  159. {
  160. m_nFlags |= bitsFIRESMOKE_VISIBLE_FROM_ABOVE;
  161. }
  162. else
  163. {
  164. m_nFlags &= ~bitsFIRESMOKE_VISIBLE_FROM_ABOVE;
  165. }
  166. }