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.

515 lines
19 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "cbase.h"
  8. #include "te.h"
  9. #include "effect_dispatch_data.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. // External definitions
  13. void TE_ArmorRicochet( IRecipientFilter& filter, float delay,
  14. const Vector* pos, const Vector* dir );
  15. void TE_BeamEntPoint( IRecipientFilter& filter, float delay,
  16. int nStartEntity, const Vector *start, int nEndEntity, const Vector* end, int modelindex, int haloindex, int startframe, int framerate,
  17. float life, float width, float endWidth, int fadeLength, float amplitude,
  18. int r, int g, int b, int a, int speed );
  19. void TE_BeamEnts( IRecipientFilter& filter, float delay,
  20. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  21. float life, float width, float endWidth, int fadeLength, float amplitude,
  22. int r, int g, int b, int a, int speed );
  23. void TE_BeamFollow( IRecipientFilter& filter, float delay,
  24. int iEntIndex, int modelIndex, int haloIndex, float life, float width, float endWidth,
  25. float fadeLength,float r, float g, float b, float a );
  26. void TE_BeamPoints( IRecipientFilter& filter, float delay,
  27. const Vector* start, const Vector* end, int modelindex, int haloindex, int startframe, int framerate,
  28. float life, float width, float endWidth, int fadeLength, float amplitude,
  29. int r, int g, int b, int a, int speed );
  30. void TE_BeamLaser( IRecipientFilter& filter, float delay,
  31. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  32. float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed );
  33. void TE_BeamRing( IRecipientFilter& filter, float delay,
  34. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  35. float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags = 0 );
  36. void TE_BeamRingPoint( IRecipientFilter& filter, float delay,
  37. const Vector& center, float start_radius, float end_radius, int modelindex, int haloindex, int startframe, int framerate,
  38. float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags = 0 );
  39. void TE_BeamSpline( IRecipientFilter& filter, float delay,
  40. int points, Vector* rgPoints );
  41. void TE_BloodStream( IRecipientFilter& filter, float delay,
  42. const Vector* org, const Vector* dir, int r, int g, int b, int a, int amount );
  43. void TE_BloodSprite( IRecipientFilter& filter, float delay,
  44. const Vector* org, const Vector *dir, int r, int g, int b, int a, int size );
  45. void TE_BreakModel( IRecipientFilter& filter, float delay,
  46. const Vector& pos, const QAngle &angles, const Vector& size, const Vector& vel,
  47. int modelindex, int randomization, int count, float time, int flags );
  48. void TE_BSPDecal( IRecipientFilter& filter, float delay,
  49. const Vector* pos, int entity, int index );
  50. void TE_ProjectDecal( IRecipientFilter& filer, float delay,
  51. const Vector* pos, const QAngle *angles, float distance, int index );
  52. void TE_Bubbles( IRecipientFilter& filter, float delay,
  53. const Vector* mins, const Vector* maxs, float height, int modelindex, int count, float speed );
  54. void TE_BubbleTrail( IRecipientFilter& filter, float delay,
  55. const Vector* mins, const Vector* maxs, float height, int modelindex, int count, float speed );
  56. void TE_Decal( IRecipientFilter& filter, float delay,
  57. const Vector* pos, const Vector* start, int entity, int hitbox, int index );
  58. void TE_DynamicLight( IRecipientFilter& filter, float delay,
  59. const Vector* org, int r, int g, int b, int exponent, float radius, float time, float decay );
  60. void TE_Explosion( IRecipientFilter& filter, float delay,
  61. const Vector& pos, int modelindex, float scale, int framerate, int flags, int radius, int magnitude, const Vector& normal, unsigned char materialType = 'C' );
  62. void TE_ShatterSurface( IRecipientFilter& filter, float delay,
  63. const Vector* pos, const QAngle* angle, const Vector* vForce, const Vector* vForcePos,
  64. float width, float height, float shardsize, ShatterSurface_t surfacetype,
  65. int front_r, int front_g, int front_b, int back_r, int back_g, int back_b);
  66. void TE_GlowSprite( IRecipientFilter& filter, float delay,
  67. const Vector* pos, int modelindex, float life, float size, int brightness );
  68. void TE_FootprintDecal( IRecipientFilter& filter, float delay, const Vector *origin, const Vector* right,
  69. int entity, int index, unsigned char materialType );
  70. void TE_Fizz( IRecipientFilter& filter, float delay,
  71. const CBaseEntity *ed, int modelindex, int density, int current );
  72. void TE_KillPlayerAttachments( IRecipientFilter& filter, float delay,
  73. int player );
  74. void TE_LargeFunnel( IRecipientFilter& filter, float delay,
  75. const Vector* pos, int modelindex, int reversed );
  76. void TE_MetalSparks( IRecipientFilter& filter, float delay,
  77. const Vector* pos, const Vector* dir );
  78. void TE_EnergySplash( IRecipientFilter& filter, float delay,
  79. const Vector* pos, const Vector* dir, bool bExplosive );
  80. void TE_PlayerDecal( IRecipientFilter& filter, float delay,
  81. const Vector* pos, const Vector* start, const Vector* right, int player, int entity, int hitbox );
  82. void TE_ShowLine( IRecipientFilter& filter, float delay,
  83. const Vector* start, const Vector* end );
  84. void TE_Smoke( IRecipientFilter& filter, float delay,
  85. const Vector* pos, int modelindex, float scale, int framerate );
  86. void TE_Sparks( IRecipientFilter& filter, float delay,
  87. const Vector* pos, int nMagnitude, int nTrailLength, const Vector *pDir );
  88. void TE_Sprite( IRecipientFilter& filter, float delay,
  89. const Vector* pos, int modelindex, float size, int brightness );
  90. void TE_SpriteSpray( IRecipientFilter& filter, float delay,
  91. const Vector* pos, const Vector* dir, int modelindex, int speed, float noise, int count );
  92. void TE_WorldDecal( IRecipientFilter& filter, float delay,
  93. const Vector* pos, int index );
  94. void TE_MuzzleFlash( IRecipientFilter& filter, float delayt,
  95. const Vector &start, const QAngle &angles, float scale, int type );
  96. void TE_Dust( IRecipientFilter& filter, float delayt,
  97. const Vector &pos, const Vector &dir, float size, float speed );
  98. void TE_PhysicsProp( IRecipientFilter& filter, float delay,
  99. int modelindex, int skin, const Vector& pos, const QAngle &angles, const Vector& vel, int flags, int effects, color24 color );
  100. void TE_ClientProjectile( IRecipientFilter& filter, float delay,
  101. const Vector* vecOrigin, const Vector* vecVelocity, int modelindex, int lifetime, CBaseEntity *pOwner );
  102. #ifdef HL2_DLL
  103. void TE_GaussExplosion( IRecipientFilter& filter, float delayt,
  104. const Vector &pos, const Vector &dir, int type );
  105. #endif
  106. class CTempEntsSystem : public ITempEntsSystem
  107. {
  108. //-----------------------------------------------------------------------------
  109. // Purpose: Returning true means don't even call TE func
  110. // Input : filter -
  111. // *suppress_host -
  112. // Output : static bool
  113. //-----------------------------------------------------------------------------
  114. bool SuppressTE( IRecipientFilter& filter )
  115. {
  116. if ( GetSuppressHost() )
  117. {
  118. CRecipientFilter& _filter = (( CRecipientFilter & )filter);
  119. if ( !_filter.IgnorePredictionCull() )
  120. {
  121. _filter.RemoveRecipient( (CBasePlayer *)GetSuppressHost() );
  122. }
  123. if ( !_filter.GetRecipientCount() )
  124. {
  125. // Suppress it
  126. return true;
  127. }
  128. }
  129. // There's at least one recipient
  130. return false;
  131. }
  132. public:
  133. virtual void ArmorRicochet( IRecipientFilter& filter, float delay,
  134. const Vector* pos, const Vector* dir )
  135. {
  136. if ( !SuppressTE( filter ) )
  137. {
  138. TE_ArmorRicochet( filter, delay, pos, dir );
  139. }
  140. }
  141. virtual void BeamEntPoint( IRecipientFilter& filter, float delay,
  142. int nStartEntity, const Vector *pStart, int nEndEntity, const Vector* pEnd,
  143. int modelindex, int haloindex, int startframe, int framerate,
  144. float life, float width, float endWidth, int fadeLength, float amplitude,
  145. int r, int g, int b, int a, int speed )
  146. {
  147. if ( !SuppressTE( filter ) )
  148. {
  149. TE_BeamEntPoint( filter, delay, nStartEntity, pStart, nEndEntity, pEnd, modelindex, haloindex, startframe, framerate,
  150. life, width, endWidth, fadeLength, amplitude, r, g, b, a, speed );
  151. }
  152. }
  153. virtual void BeamEnts( IRecipientFilter& filter, float delay,
  154. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  155. float life, float width, float endWidth, int fadeLength, float amplitude,
  156. int r, int g, int b, int a, int speed )
  157. {
  158. if ( !SuppressTE( filter ) )
  159. {
  160. TE_BeamEnts( filter, delay,
  161. start, end, modelindex, haloindex, startframe, framerate,
  162. life, width, endWidth, fadeLength, amplitude,
  163. r, g, b, a, speed );
  164. }
  165. }
  166. virtual void BeamFollow( IRecipientFilter& filter, float delay,
  167. int iEntIndex, int modelIndex, int haloIndex, float life, float width, float endWidth,
  168. float fadeLength, float r, float g, float b, float a )
  169. {
  170. if ( !SuppressTE( filter ) )
  171. {
  172. TE_BeamFollow( filter, delay,
  173. iEntIndex, modelIndex, haloIndex, life, width, endWidth, fadeLength,
  174. r, g, b, a );
  175. }
  176. }
  177. virtual void BeamPoints( IRecipientFilter& filter, float delay,
  178. const Vector* start, const Vector* end, int modelindex, int haloindex, int startframe, int framerate,
  179. float life, float width, float endWidth, int fadeLength, float amplitude,
  180. int r, int g, int b, int a, int speed )
  181. {
  182. if ( !SuppressTE( filter ) )
  183. {
  184. TE_BeamPoints( filter, delay,
  185. start, end, modelindex, haloindex, startframe, framerate,
  186. life, width, endWidth, fadeLength, amplitude,
  187. r, g, b, a, speed );
  188. }
  189. }
  190. virtual void BeamLaser( IRecipientFilter& filter, float delay,
  191. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  192. float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed )
  193. {
  194. if ( !SuppressTE( filter ) )
  195. {
  196. TE_BeamLaser( filter, delay,
  197. start, end, modelindex, haloindex, startframe, framerate,
  198. life, width, endWidth, fadeLength, amplitude, r, g, b, a, speed );
  199. }
  200. }
  201. virtual void BeamRing( IRecipientFilter& filter, float delay,
  202. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  203. float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags )
  204. {
  205. if ( !SuppressTE( filter ) )
  206. {
  207. TE_BeamRing( filter, delay,
  208. start, end, modelindex, haloindex, startframe, framerate,
  209. life, width, spread, amplitude, r, g, b, a, speed, flags );
  210. }
  211. }
  212. virtual void BeamRingPoint( IRecipientFilter& filter, float delay,
  213. const Vector& center, float start_radius, float end_radius, int modelindex, int haloindex, int startframe, int framerate,
  214. float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags )
  215. {
  216. if ( !SuppressTE( filter ) )
  217. {
  218. TE_BeamRingPoint( filter, delay,
  219. center, start_radius, end_radius, modelindex, haloindex, startframe, framerate,
  220. life, width, spread, amplitude, r, g, b, a, speed, flags );
  221. }
  222. }
  223. virtual void BeamSpline( IRecipientFilter& filter, float delay,
  224. int points, Vector* rgPoints )
  225. {
  226. if ( !SuppressTE( filter ) )
  227. {
  228. TE_BeamSpline( filter, delay, points, rgPoints );
  229. }
  230. }
  231. virtual void BloodStream( IRecipientFilter& filter, float delay,
  232. const Vector* org, const Vector* dir, int r, int g, int b, int a, int amount )
  233. {
  234. if ( !SuppressTE( filter ) )
  235. {
  236. TE_BloodStream( filter, delay, org, dir, r, g, b, a, amount );
  237. }
  238. }
  239. virtual void BloodSprite( IRecipientFilter& filter, float delay,
  240. const Vector* org, const Vector *dir, int r, int g, int b, int a, int size )
  241. {
  242. if ( !SuppressTE( filter ) )
  243. {
  244. TE_BloodSprite( filter, delay, org, dir, r, g, b, a, size );
  245. }
  246. }
  247. virtual void BreakModel( IRecipientFilter& filter, float delay,
  248. const Vector& pos, const QAngle &angle, const Vector& size, const Vector& vel,
  249. int modelindex, int randomization, int count, float time, int flags )
  250. {
  251. if ( !SuppressTE( filter ) )
  252. {
  253. TE_BreakModel( filter, delay, pos, angle, size, vel, modelindex, randomization, count, time, flags );
  254. }
  255. }
  256. virtual void BSPDecal( IRecipientFilter& filter, float delay,
  257. const Vector* pos, int entity, int index )
  258. {
  259. if ( !SuppressTE( filter ) )
  260. {
  261. TE_BSPDecal( filter, delay, pos, entity, index );
  262. }
  263. }
  264. virtual void ProjectDecal( IRecipientFilter& filter, float delay,
  265. const Vector* pos, const QAngle *angles, float distance, int index )
  266. {
  267. if ( !SuppressTE( filter ) )
  268. {
  269. TE_ProjectDecal( filter, delay, pos, angles, distance, index );
  270. }
  271. }
  272. virtual void Bubbles( IRecipientFilter& filter, float delay,
  273. const Vector* mins, const Vector* maxs, float height, int modelindex, int count, float speed )
  274. {
  275. if ( !SuppressTE( filter ) )
  276. {
  277. TE_Bubbles( filter, delay, mins, maxs, height, modelindex, count, speed );
  278. }
  279. }
  280. virtual void BubbleTrail( IRecipientFilter& filter, float delay,
  281. const Vector* mins, const Vector* maxs, float flWaterZ, int modelindex, int count, float speed )
  282. {
  283. if ( !SuppressTE( filter ) )
  284. {
  285. TE_BubbleTrail( filter, delay, mins, maxs, flWaterZ, modelindex, count, speed );
  286. }
  287. }
  288. virtual void Decal( IRecipientFilter& filter, float delay,
  289. const Vector* pos, const Vector* start, int entity, int hitbox, int index )
  290. {
  291. if ( !SuppressTE( filter ) )
  292. {
  293. TE_Decal( filter, delay, pos, start, entity, hitbox, index );
  294. }
  295. }
  296. virtual void DynamicLight( IRecipientFilter& filter, float delay,
  297. const Vector* org, int r, int g, int b, int exponent, float radius, float time, float decay )
  298. {
  299. if ( !SuppressTE( filter ) )
  300. {
  301. TE_DynamicLight( filter, delay, org, r, g, b, exponent, radius, time, decay );
  302. }
  303. }
  304. virtual void Explosion( IRecipientFilter& filter, float delay,
  305. const Vector& pos, int modelindex, float scale, int framerate, int flags, int radius, int magnitude, const Vector* pNormal = NULL, unsigned char materialType = 'C' )
  306. {
  307. if ( !SuppressTE( filter ) )
  308. {
  309. Vector normal = pNormal ? *pNormal : Vector( 0, 0, 1 );
  310. TE_Explosion( filter, delay, pos, modelindex, scale, framerate, flags, radius, magnitude, normal, materialType );
  311. }
  312. }
  313. virtual void ShatterSurface( IRecipientFilter& filter, float delay,
  314. const Vector* pos, const QAngle* angle, const Vector* vForce, const Vector* vForcePos,
  315. float width, float height, float shardsize, ShatterSurface_t surfacetype,
  316. int front_r, int front_g, int front_b, int back_r, int back_g, int back_b)
  317. {
  318. if ( !SuppressTE( filter ) )
  319. {
  320. TE_ShatterSurface( filter, delay, pos, angle, vForce, vForcePos, width, height, shardsize, surfacetype,
  321. front_r, front_g, front_b, back_r, back_g, back_b );
  322. }
  323. }
  324. virtual void GlowSprite( IRecipientFilter& filter, float delay,
  325. const Vector* pos, int modelindex, float life, float size, int brightness )
  326. {
  327. if ( !SuppressTE( filter ) )
  328. {
  329. TE_GlowSprite( filter, delay, pos, modelindex, life, size, brightness );
  330. }
  331. }
  332. virtual void FootprintDecal( IRecipientFilter& filter, float delay, const Vector *origin, const Vector* right,
  333. int entity, int index, unsigned char materialType )
  334. {
  335. if ( !SuppressTE( filter ) )
  336. {
  337. TE_FootprintDecal( filter, delay, origin, right,
  338. entity, index, materialType );
  339. }
  340. }
  341. virtual void Fizz( IRecipientFilter& filter, float delay,
  342. const CBaseEntity *ed, int modelindex, int density, int current )
  343. {
  344. if ( !SuppressTE( filter ) )
  345. {
  346. TE_Fizz( filter, delay,
  347. ed, modelindex, density, current );
  348. }
  349. }
  350. virtual void KillPlayerAttachments( IRecipientFilter& filter, float delay,
  351. int player )
  352. {
  353. if ( !SuppressTE( filter ) )
  354. {
  355. TE_KillPlayerAttachments( filter, delay, player );
  356. }
  357. }
  358. virtual void LargeFunnel( IRecipientFilter& filter, float delay,
  359. const Vector* pos, int modelindex, int reversed )
  360. {
  361. if ( !SuppressTE( filter ) )
  362. {
  363. TE_LargeFunnel( filter, delay, pos, modelindex, reversed );
  364. }
  365. }
  366. virtual void MetalSparks( IRecipientFilter& filter, float delay,
  367. const Vector* pos, const Vector* dir )
  368. {
  369. if ( !SuppressTE( filter ) )
  370. {
  371. TE_MetalSparks( filter, delay, pos, dir );
  372. }
  373. }
  374. virtual void EnergySplash( IRecipientFilter& filter, float delay,
  375. const Vector* pos, const Vector* dir, bool bExplosive )
  376. {
  377. if ( !SuppressTE( filter ) )
  378. {
  379. TE_EnergySplash( filter, delay,
  380. pos, dir, bExplosive );
  381. }
  382. }
  383. virtual void PlayerDecal( IRecipientFilter& filter, float delay,
  384. const Vector* pos, const Vector *start, const Vector* right, int player, int entity, int hitbox )
  385. {
  386. if ( !SuppressTE( filter ) )
  387. {
  388. TE_PlayerDecal( filter, delay,
  389. pos, start, right, player, entity, hitbox );
  390. }
  391. }
  392. virtual void ShowLine( IRecipientFilter& filter, float delay,
  393. const Vector* start, const Vector* end )
  394. {
  395. if ( !SuppressTE( filter ) )
  396. {
  397. TE_ShowLine( filter, delay,
  398. start, end );
  399. }
  400. }
  401. virtual void Smoke( IRecipientFilter& filter, float delay,
  402. const Vector* pos, int modelindex, float scale, int framerate )
  403. {
  404. if ( !SuppressTE( filter ) )
  405. {
  406. TE_Smoke( filter, delay,
  407. pos, modelindex, scale, framerate );
  408. }
  409. }
  410. virtual void Sparks( IRecipientFilter& filter, float delay,
  411. const Vector* pos, int nMagnitude, int nTrailLength, const Vector *pDir )
  412. {
  413. if ( !SuppressTE( filter ) )
  414. {
  415. TE_Sparks( filter, delay,
  416. pos, nMagnitude, nTrailLength, pDir );
  417. }
  418. }
  419. virtual void Sprite( IRecipientFilter& filter, float delay,
  420. const Vector* pos, int modelindex, float size, int brightness )
  421. {
  422. if ( !SuppressTE( filter ) )
  423. {
  424. TE_Sprite( filter, delay,
  425. pos, modelindex, size, brightness );
  426. }
  427. }
  428. virtual void SpriteSpray( IRecipientFilter& filter, float delay,
  429. const Vector* pos, const Vector* dir, int modelindex, int speed, float noise, int count )
  430. {
  431. if ( !SuppressTE( filter ) )
  432. {
  433. TE_SpriteSpray( filter, delay,
  434. pos, dir, modelindex, speed, noise, count );
  435. }
  436. }
  437. virtual void WorldDecal( IRecipientFilter& filter, float delay,
  438. const Vector* pos, int index )
  439. {
  440. if ( !SuppressTE( filter ) )
  441. {
  442. TE_WorldDecal( filter, delay,
  443. pos, index );
  444. }
  445. }
  446. virtual void MuzzleFlash( IRecipientFilter& filter, float delay,
  447. const Vector &start, const QAngle &angles, float scale, int type )
  448. {
  449. if ( !SuppressTE( filter ) )
  450. {
  451. TE_MuzzleFlash( filter, delay,
  452. start, angles, scale, type );
  453. }
  454. }
  455. virtual void Dust( IRecipientFilter& filter, float delay,
  456. const Vector &pos, const Vector &dir, float size, float speed )
  457. {
  458. if ( !SuppressTE( filter ) )
  459. {
  460. TE_Dust( filter, delay,
  461. pos, dir, size, speed );
  462. }
  463. }
  464. virtual void GaussExplosion( IRecipientFilter& filter, float delay,
  465. const Vector &pos, const Vector &dir, int type )
  466. {
  467. #ifdef HL2_DLL
  468. if ( !SuppressTE( filter ) )
  469. {
  470. TE_GaussExplosion( filter, delay, pos, dir, type );
  471. }
  472. #endif
  473. }
  474. virtual void PhysicsProp( IRecipientFilter& filter, float delay, int modelindex, int skin,
  475. const Vector& pos, const QAngle &angles, const Vector& vel, int flags, int effects, color24 renderColor )
  476. {
  477. if ( !SuppressTE( filter ) )
  478. {
  479. TE_PhysicsProp( filter, delay, modelindex, skin, pos, angles, vel, flags, effects, renderColor );
  480. }
  481. }
  482. // For playback from external tools
  483. virtual void TriggerTempEntity( KeyValues *pKeyValues )
  484. {
  485. Assert(0);
  486. }
  487. virtual void ClientProjectile( IRecipientFilter& filter, float delay,
  488. const Vector* vecOrigin, const Vector* vecVelocity, int modelindex, int lifetime, CBaseEntity *pOwner )
  489. {
  490. if ( !SuppressTE( filter ) )
  491. {
  492. TE_ClientProjectile( filter, delay, vecOrigin, vecVelocity, modelindex, lifetime, pOwner );
  493. }
  494. }
  495. };
  496. static CTempEntsSystem g_TESystem;
  497. // Expose to rest of engine
  498. ITempEntsSystem *te = &g_TESystem;