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.

264 lines
7.3 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "cbase.h"
  8. #include "iviewrender.h"
  9. #include "precache_register.h"
  10. #include "studio.h"
  11. #include "bone_setup.h"
  12. #include "engine/ivmodelinfo.h"
  13. #include "c_fire_smoke.h"
  14. #include "engine/IEngineSound.h"
  15. #include "iefx.h"
  16. #include "dlight.h"
  17. #include "tier0/icommandline.h"
  18. // memdbgon must be the last include file in a .cpp file!!!
  19. #include "tier0/memdbgon.h"
  20. PRECACHE_REGISTER_BEGIN( GLOBAL, SmokeStackMaterials )
  21. PRECACHE( MATERIAL, "particle/SmokeStack" )
  22. PRECACHE_REGISTER_END()
  23. //-----------------------------------------------------------------------------
  24. // Purpose:
  25. // Input : *pRecvProp -
  26. // *pStruct -
  27. // *pVarData -
  28. // *pIn -
  29. // objectID -
  30. //-----------------------------------------------------------------------------
  31. void RecvProxy_Scale( const CRecvProxyData *pData, void *pStruct, void *pOut )
  32. {
  33. C_FireSmoke *pFireSmoke = (C_FireSmoke *) pStruct;
  34. float scale = pData->m_Value.m_Float;
  35. //If changed, update our internal information
  36. if ( ( pFireSmoke->m_flScale != scale ) && ( pFireSmoke->m_flScaleEnd != scale ) )
  37. {
  38. pFireSmoke->m_flScaleStart = pFireSmoke->m_flScaleRegister;
  39. pFireSmoke->m_flScaleEnd = scale;
  40. }
  41. pFireSmoke->m_flScale = scale;
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. // Input : *pRecvProp -
  46. // *pStruct -
  47. // *pVarData -
  48. // *pIn -
  49. // objectID -
  50. //-----------------------------------------------------------------------------
  51. void RecvProxy_ScaleTime( const CRecvProxyData *pData, void *pStruct, void *pOut )
  52. {
  53. C_FireSmoke *pFireSmoke = (C_FireSmoke *) pStruct;
  54. float time = pData->m_Value.m_Float;
  55. //If changed, update our internal information
  56. //if ( pFireSmoke->m_flScaleTime != time )
  57. {
  58. if ( time == -1.0f )
  59. {
  60. pFireSmoke->m_flScaleTimeStart = Helper_GetTime()-1.0f;
  61. pFireSmoke->m_flScaleTimeEnd = pFireSmoke->m_flScaleTimeStart;
  62. }
  63. else
  64. {
  65. pFireSmoke->m_flScaleTimeStart = Helper_GetTime();
  66. pFireSmoke->m_flScaleTimeEnd = Helper_GetTime() + time;
  67. }
  68. }
  69. pFireSmoke->m_flScaleTime = time;
  70. }
  71. //Receive datatable
  72. IMPLEMENT_CLIENTCLASS_DT( C_FireSmoke, DT_FireSmoke, CFireSmoke )
  73. RecvPropFloat( RECVINFO( m_flStartScale )),
  74. RecvPropFloat( RECVINFO( m_flScale ), 0, RecvProxy_Scale ),
  75. RecvPropFloat( RECVINFO( m_flScaleTime ), 0, RecvProxy_ScaleTime ),
  76. RecvPropInt( RECVINFO( m_nFlags ) ),
  77. RecvPropInt( RECVINFO( m_nFlameModelIndex ) ),
  78. RecvPropInt( RECVINFO( m_nFlameFromAboveModelIndex ) ),
  79. END_RECV_TABLE()
  80. //==================================================
  81. // C_FireSmoke
  82. //==================================================
  83. C_FireSmoke::C_FireSmoke()
  84. {
  85. }
  86. C_FireSmoke::~C_FireSmoke()
  87. {
  88. // Shut down our effect if we have it
  89. if ( m_hEffect )
  90. {
  91. m_hEffect->StopEmission(false, false , true);
  92. m_hEffect = NULL;
  93. }
  94. }
  95. #define FLAME_ALPHA_START 0.9f
  96. #define FLAME_ALPHA_END 1.0f
  97. #define FLAME_TRANS_START 0.75f
  98. //-----------------------------------------------------------------------------
  99. // Purpose:
  100. //-----------------------------------------------------------------------------
  101. void C_FireSmoke::AddFlames( void )
  102. {
  103. }
  104. //-----------------------------------------------------------------------------
  105. // Purpose:
  106. // Input : bnewentity -
  107. //-----------------------------------------------------------------------------
  108. void C_FireSmoke::OnDataChanged( DataUpdateType_t updateType )
  109. {
  110. BaseClass::OnDataChanged( updateType );
  111. if ( updateType == DATA_UPDATE_CREATED )
  112. {
  113. Start();
  114. }
  115. }
  116. //-----------------------------------------------------------------------------
  117. // Purpose:
  118. //-----------------------------------------------------------------------------
  119. void C_FireSmoke::UpdateEffects( void )
  120. {
  121. }
  122. //-----------------------------------------------------------------------------
  123. // Purpose:
  124. // Output : Returns true on success, false on failure.
  125. //-----------------------------------------------------------------------------
  126. bool C_FireSmoke::ShouldDraw()
  127. {
  128. return true;
  129. }
  130. //-----------------------------------------------------------------------------
  131. // Purpose:
  132. //-----------------------------------------------------------------------------
  133. void C_FireSmoke::Start( void )
  134. {
  135. const char *lpszEffectName;
  136. int nSize = (int) floor( m_flStartScale / 36.0f );
  137. RANDOM_CEG_TEST_SECRET_PERIOD( 36, 67 );
  138. switch ( nSize )
  139. {
  140. case 0:
  141. lpszEffectName = ( m_nFlags & bitsFIRESMOKE_SMOKE ) ? "env_fire_tiny_smoke" : "env_fire_tiny";
  142. break;
  143. case 1:
  144. lpszEffectName = ( m_nFlags & bitsFIRESMOKE_SMOKE ) ? "env_fire_small_smoke" : "env_fire_small";
  145. break;
  146. case 2:
  147. lpszEffectName = ( m_nFlags & bitsFIRESMOKE_SMOKE ) ? "env_fire_medium_smoke" : "env_fire_medium";
  148. break;
  149. case 3:
  150. default:
  151. lpszEffectName = ( m_nFlags & bitsFIRESMOKE_SMOKE ) ? "env_fire_large_smoke" : "env_fire_large";
  152. break;
  153. }
  154. // Create the effect of the correct size
  155. m_hEffect = ParticleProp()->Create( lpszEffectName, PATTACH_ABSORIGIN );
  156. }
  157. //-----------------------------------------------------------------------------
  158. // Purpose: FIXME: what's the right way to do this?
  159. //-----------------------------------------------------------------------------
  160. void C_FireSmoke::StartClientOnly( void )
  161. {
  162. Start();
  163. ClientEntityList().AddNonNetworkableEntity( this );
  164. CollisionProp()->CreatePartitionHandle();
  165. AddEffects( EF_NORECEIVESHADOW | EF_NOSHADOW );
  166. AddToLeafSystem();
  167. }
  168. //-----------------------------------------------------------------------------
  169. // Purpose:
  170. //-----------------------------------------------------------------------------
  171. void C_FireSmoke::RemoveClientOnly(void)
  172. {
  173. ClientThinkList()->RemoveThinkable( GetClientHandle() );
  174. // Remove from the client entity list.
  175. ClientEntityList().RemoveEntity( GetClientHandle() );
  176. ::partition->Remove( PARTITION_CLIENT_SOLID_EDICTS | PARTITION_CLIENT_RESPONSIVE_EDICTS | PARTITION_CLIENT_NON_STATIC_EDICTS, CollisionProp()->GetPartitionHandle() );
  177. RemoveFromLeafSystem();
  178. }
  179. //-----------------------------------------------------------------------------
  180. // Purpose:
  181. //-----------------------------------------------------------------------------
  182. void C_FireSmoke::UpdateAnimation( void )
  183. {
  184. }
  185. //-----------------------------------------------------------------------------
  186. // Purpose:
  187. //-----------------------------------------------------------------------------
  188. void C_FireSmoke::UpdateFlames( void )
  189. {
  190. }
  191. //-----------------------------------------------------------------------------
  192. // Purpose:
  193. //-----------------------------------------------------------------------------
  194. void C_FireSmoke::UpdateScale( void )
  195. {
  196. }
  197. //-----------------------------------------------------------------------------
  198. // Purpose:
  199. //-----------------------------------------------------------------------------
  200. void C_FireSmoke::Update( void )
  201. {
  202. }
  203. //-----------------------------------------------------------------------------
  204. // Purpose:
  205. //-----------------------------------------------------------------------------
  206. void C_FireSmoke::FindClipPlane( void )
  207. {
  208. }
  209. //-----------------------------------------------------------------------------
  210. // Purpose: Spawn smoke (...duh)
  211. //-----------------------------------------------------------------------------
  212. void C_FireSmoke::SpawnSmoke( void )
  213. {
  214. }