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.

208 lines
9.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #if !defined( C_TE_LEGACYTEMPENTS_H )
  10. #define C_TE_LEGACYTEMPENTS_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. class C_BaseEntity;
  15. class C_LocalTempEntity;
  16. struct model_t;
  17. #include "mempool.h"
  18. #include "utllinkedlist.h"
  19. extern color24 white24;
  20. #if defined( CSTRIKE_DLL ) || defined( SDK_DLL )
  21. enum
  22. {
  23. CS_SHELL_9MM = 0,
  24. CS_SHELL_57,
  25. CS_SHELL_12GAUGE,
  26. CS_SHELL_556,
  27. CS_SHELL_762NATO,
  28. CS_SHELL_338MAG,
  29. };
  30. #endif
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Interface for lecacy temp entities
  33. //-----------------------------------------------------------------------------
  34. abstract_class ITempEnts
  35. {
  36. public:
  37. virtual ~ITempEnts() {}
  38. virtual void Init( void ) = 0;
  39. virtual void Shutdown( void ) = 0;
  40. virtual void LevelInit() = 0;
  41. virtual void LevelShutdown() = 0;
  42. virtual void Update( void ) = 0;
  43. virtual void Clear( void ) = 0;
  44. virtual C_LocalTempEntity *FindTempEntByID( int nID, int nSubID ) = 0;
  45. virtual void BloodSprite( const Vector &org, int r, int g, int b, int a, int modelIndex, int modelIndex2, float size ) = 0;
  46. virtual void RicochetSprite( const Vector &pos, model_t *pmodel, float duration, float scale ) = 0;
  47. virtual void MuzzleFlash( int type, ClientEntityHandle_t hEntity, int attachmentIndex, bool firstPerson ) = 0;
  48. virtual void MuzzleFlash( const Vector &pos1, const QAngle &angles, int type, ClientEntityHandle_t hEntity, bool firstPerson ) = 0;
  49. virtual C_LocalTempEntity *SpawnTempModel( model_t *pModel, const Vector &vecOrigin, const QAngle &vecAngles, const Vector &vecVelocity, float flLifeTime, int iFlags ) = 0;
  50. virtual void BreakModel( const Vector &pos, const QAngle &angles, const Vector &size, const Vector &dir, float random, float life, int count, int modelIndex, char flags) = 0;
  51. virtual void Bubbles( const Vector &mins, const Vector &maxs, float height, int modelIndex, int count, float speed ) = 0;
  52. virtual void BubbleTrail( const Vector &start, const Vector &end, float flWaterZ, int modelIndex, int count, float speed ) = 0;
  53. virtual void Sprite_Explode( C_LocalTempEntity *pTemp, float scale, int flags ) = 0;
  54. virtual void FizzEffect( C_BaseEntity *pent, int modelIndex, int density, int current ) = 0;
  55. virtual C_LocalTempEntity *DefaultSprite( const Vector &pos, int spriteIndex, float framerate ) = 0;
  56. virtual void Sprite_Smoke( C_LocalTempEntity *pTemp, float scale ) = 0;
  57. virtual C_LocalTempEntity *TempSprite( const Vector &pos, const Vector &dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags, const Vector &normal = vec3_origin ) = 0;
  58. virtual void AttachTentToPlayer( int client, int modelIndex, float zoffset, float life ) = 0;
  59. virtual void KillAttachedTents( int client ) = 0;
  60. virtual void Sprite_Spray( const Vector &pos, const Vector &dir, int modelIndex, int count, int speed, int iRand ) = 0;
  61. virtual void Sprite_Trail( const Vector &vecStart, const Vector &vecEnd, int modelIndex, int nCount, float flLife, float flSize, float flAmplitude, int nRenderamt, float flSpeed ) = 0;
  62. virtual void RocketFlare( const Vector& pos ) = 0;
  63. virtual void PlaySound ( C_LocalTempEntity *pTemp, float damp ) = 0;
  64. virtual void PhysicsProp( int modelindex, int skin, const Vector& pos, const QAngle &angles, const Vector& vel, int flags, int effects = 0, color24 renderColor = white24 ) = 0;
  65. virtual C_LocalTempEntity *ClientProjectile( const Vector& vecOrigin, const Vector& vecVelocity, const Vector& vecAccel, int modelindex, int lifetime, CBaseEntity *pOwner, const char *pszImpactEffect = NULL, const char *pszParticleEffect = NULL ) = 0;
  66. };
  67. //-----------------------------------------------------------------------------
  68. // Purpose: Default implementation of the temp entity interface
  69. //-----------------------------------------------------------------------------
  70. class CTempEnts : public ITempEnts
  71. {
  72. // Construction
  73. public:
  74. CTempEnts( void );
  75. virtual ~CTempEnts( void );
  76. // Exposed interface
  77. public:
  78. virtual void Init( void );
  79. virtual void Shutdown( void );
  80. virtual void LevelInit();
  81. virtual void LevelShutdown();
  82. virtual void Update( void );
  83. virtual void Clear( void );
  84. virtual C_LocalTempEntity *FindTempEntByID( int nID, int nSubID );
  85. // Legacy temp entities still supported
  86. virtual void BloodSprite( const Vector &org, int r, int g, int b, int a, int modelIndex, int modelIndex2, float size );
  87. virtual void RicochetSprite( const Vector &pos, model_t *pmodel, float duration, float scale );
  88. virtual void MuzzleFlash( int type, ClientEntityHandle_t hEntity, int attachmentIndex, bool firstPerson );
  89. virtual void MuzzleFlash( const Vector &pos1, const QAngle &angles, int type, ClientEntityHandle_t hEntity, bool firstPerson = false );
  90. virtual void BreakModel(const Vector &pos, const QAngle &angles, const Vector &size, const Vector &dir, float random, float life, int count, int modelIndex, char flags);
  91. virtual void Bubbles( const Vector &mins, const Vector &maxs, float height, int modelIndex, int count, float speed );
  92. virtual void BubbleTrail( const Vector &start, const Vector &end, float height, int modelIndex, int count, float speed );
  93. virtual void Sprite_Explode( C_LocalTempEntity *pTemp, float scale, int flags );
  94. virtual void FizzEffect( C_BaseEntity *pent, int modelIndex, int density, int current );
  95. virtual C_LocalTempEntity *DefaultSprite( const Vector &pos, int spriteIndex, float framerate );
  96. virtual void Sprite_Smoke( C_LocalTempEntity *pTemp, float scale );
  97. virtual C_LocalTempEntity *TempSprite( const Vector &pos, const Vector &dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags, const Vector &normal = vec3_origin );
  98. virtual void AttachTentToPlayer( int client, int modelIndex, float zoffset, float life );
  99. virtual void KillAttachedTents( int client );
  100. virtual void Sprite_Spray( const Vector &pos, const Vector &dir, int modelIndex, int count, int speed, int iRand );
  101. void Sprite_Trail( const Vector &vecStart, const Vector &vecEnd, int modelIndex, int nCount, float flLife, float flSize, float flAmplitude, int nRenderamt, float flSpeed );
  102. virtual void PlaySound ( C_LocalTempEntity *pTemp, float damp );
  103. virtual C_LocalTempEntity *SpawnTempModel( model_t *pModel, const Vector &vecOrigin, const QAngle &vecAngles, const Vector &vecVelocity, float flLifeTime, int iFlags );
  104. void RocketFlare( const Vector& pos );
  105. void PhysicsProp( int modelindex, int skin, const Vector& pos, const QAngle &angles, const Vector& vel, int flags, int effects = 0, color24 renderColor = white24 );
  106. C_LocalTempEntity *ClientProjectile( const Vector& vecOrigin, const Vector& vecVelocity, const Vector& vecAcceleration, int modelindex, int lifetime, CBaseEntity *pOwner, const char *pszImpactEffect = NULL, const char *pszParticleEffect = NULL );
  107. // Data
  108. enum
  109. {
  110. MAX_TEMP_ENTITIES = 500,
  111. MAX_TEMP_ENTITY_SPRITES = 200,
  112. MAX_TEMP_ENTITY_STUDIOMODEL = 50,
  113. };
  114. private:
  115. // Global temp entity pool
  116. CClassMemoryPool< C_LocalTempEntity > m_TempEntsPool;
  117. CUtlLinkedList< C_LocalTempEntity *, unsigned short > m_TempEnts;
  118. // Muzzle flash sprites
  119. struct model_t *m_pSpriteMuzzleFlash[10];
  120. struct model_t *m_pSpriteAR2Flash[4];
  121. struct model_t *m_pShells[3];
  122. struct model_t *m_pSpriteCombineFlash[2];
  123. #if defined( CSTRIKE_DLL ) || defined ( SDK_DLL )
  124. struct model_t *m_pCS_9MMShell;
  125. struct model_t *m_pCS_57Shell;
  126. struct model_t *m_pCS_12GaugeShell;
  127. struct model_t *m_pCS_556Shell;
  128. struct model_t *m_pCS_762NATOShell;
  129. struct model_t *m_pCS_338MAGShell;
  130. #endif
  131. // Internal methods also available to children
  132. protected:
  133. C_LocalTempEntity *TempEntAlloc( const Vector& org, model_t *model );
  134. C_LocalTempEntity *TempEntAllocHigh( const Vector& org, model_t *model );
  135. // Material handle caches
  136. private:
  137. inline void CacheMuzzleFlashes( void );
  138. PMaterialHandle m_Material_MuzzleFlash_Player[4];
  139. PMaterialHandle m_Material_MuzzleFlash_NPC[4];
  140. PMaterialHandle m_Material_Combine_MuzzleFlash_Player[2];
  141. PMaterialHandle m_Material_Combine_MuzzleFlash_NPC[2];
  142. // Internal methods
  143. private:
  144. CTempEnts( const CTempEnts & );
  145. void TempEntFree( int index );
  146. C_LocalTempEntity *TempEntAlloc();
  147. bool FreeLowPriorityTempEnt();
  148. int AddVisibleTempEntity( C_LocalTempEntity *pEntity );
  149. // AR2
  150. void MuzzleFlash_AR2_Player( const Vector &origin, const QAngle &angles, ClientEntityHandle_t hEntity );
  151. void MuzzleFlash_AR2_NPC( const Vector &origin, const QAngle &angles, ClientEntityHandle_t hEntity );
  152. // SMG1
  153. void MuzzleFlash_SMG1_Player( ClientEntityHandle_t hEntity, int attachmentIndex );
  154. void MuzzleFlash_SMG1_NPC( ClientEntityHandle_t hEntity, int attachmentIndex );
  155. // Shotgun
  156. void MuzzleFlash_Shotgun_Player( ClientEntityHandle_t hEntity, int attachmentIndex );
  157. void MuzzleFlash_Shotgun_NPC( ClientEntityHandle_t hEntity, int attachmentIndex );
  158. // Pistol
  159. void MuzzleFlash_Pistol_Player( ClientEntityHandle_t hEntity, int attachmentIndex );
  160. void MuzzleFlash_Pistol_NPC( ClientEntityHandle_t hEntity, int attachmentIndex );
  161. // Combine
  162. void MuzzleFlash_Combine_Player( ClientEntityHandle_t hEntity, int attachmentIndex );
  163. void MuzzleFlash_Combine_NPC( ClientEntityHandle_t hEntity, int attachmentIndex );
  164. // 357
  165. void MuzzleFlash_357_Player( ClientEntityHandle_t hEntity, int attachmentIndex );
  166. // RPG
  167. void MuzzleFlash_RPG_NPC( ClientEntityHandle_t hEntity, int attachmentIndex );
  168. };
  169. extern ITempEnts *tempents;
  170. #endif // C_TE_LEGACYTEMPENTS_H