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.

124 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: A gib is a chunk of a body, or a piece of wood/metal/rocks/etc.
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef GIB_H
  10. #define GIB_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "baseanimating.h"
  15. #include "player_pickup.h"
  16. #include "Sprite.h"
  17. extern CBaseEntity *CreateRagGib( const char *szModel, const Vector &vecOrigin, const QAngle &vecAngles, const Vector &vecForce, float flFadeTime = 0.0, bool bShouldIgnite = false );
  18. #define GERMAN_GIB_COUNT 4
  19. #define HUMAN_GIB_COUNT 6
  20. #define ALIEN_GIB_COUNT 4
  21. enum GibType_e
  22. {
  23. GIB_HUMAN,
  24. GIB_ALIEN,
  25. };
  26. class CGib : public CBaseAnimating,
  27. public CDefaultPlayerPickupVPhysics
  28. {
  29. public:
  30. DECLARE_CLASS( CGib, CBaseAnimating );
  31. virtual ~CGib( void );
  32. void Spawn( const char *szGibModel, float flLifetime = 25.0f );
  33. void InitGib( CBaseEntity *pVictim, float fMaxVelocity, float fMinVelocity );
  34. void BounceGibTouch ( CBaseEntity *pOther );
  35. void StickyGibTouch ( CBaseEntity *pOther );
  36. void WaitTillLand( void );
  37. void DieThink( void );
  38. void LimitVelocity( void );
  39. virtual bool SUB_AllowedToFade( void );
  40. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  41. virtual int ObjectCaps( void ) { return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE | FCAP_IMPULSE_USE; }
  42. static void SpawnHeadGib( CBaseEntity *pVictim );
  43. static void SpawnRandomGibs( CBaseEntity *pVictim, int cGibs, GibType_e eGibType );
  44. static void SpawnStickyGibs( CBaseEntity *pVictim, Vector vecOrigin, int cGibs );
  45. static void SpawnSpecificGibs( CBaseEntity *pVictim, int nNumGibs, float fMaxVelocity, float fMinVelocity, const char* cModelName, float flLifetime = 25);
  46. void SetPhysicsAttacker( CBasePlayer *pEntity, float flTime );
  47. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason );
  48. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t reason );
  49. virtual CBasePlayer *HasPhysicsAttacker( float dt );
  50. void SetSprite( CBaseEntity *pSprite )
  51. {
  52. m_hSprite = pSprite;
  53. }
  54. CBaseEntity *GetSprite( void )
  55. {
  56. return m_hSprite.Get();
  57. }
  58. void SetFlame( CBaseEntity *pFlame )
  59. {
  60. m_hFlame = pFlame;
  61. }
  62. CBaseEntity *GetFlame( void )
  63. {
  64. return m_hFlame.Get();
  65. }
  66. DECLARE_DATADESC();
  67. public:
  68. void SetBloodColor( int nBloodColor );
  69. int m_cBloodDecals;
  70. int m_material;
  71. float m_lifeTime;
  72. bool m_bForceRemove;
  73. CHandle<CBasePlayer> m_hPhysicsAttacker;
  74. float m_flLastPhysicsInfluenceTime;
  75. private:
  76. // A little piece of duplicated code
  77. void AdjustVelocityBasedOnHealth( int nHealth, Vector &vecVelocity );
  78. int m_bloodColor;
  79. EHANDLE m_hSprite;
  80. EHANDLE m_hFlame;
  81. // Limit the max number of extant Gibs (mainly a memory issue):
  82. #ifdef _GAMECONSOLE
  83. static const int MAX_CONCURRENT_GIBS = 25;
  84. #else
  85. static const int MAX_CONCURRENT_GIBS = 75;
  86. #endif
  87. static CUtlVector<EHANDLE> s_ExtantGibs;
  88. };
  89. class CRagGib : public CBaseAnimating
  90. {
  91. public:
  92. DECLARE_CLASS( CRagGib, CBaseAnimating );
  93. void Spawn( const char *szModel, const Vector &vecOrigin, const Vector &vecForce, float flFadeTime );
  94. };
  95. #endif //GIB_H