Team Fortress 2 Source Code as on 22/4/2020
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.

115 lines
3.0 KiB

  1. //========= Copyright 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. void Spawn( const char *szGibModel );
  32. void Spawn( const char *szGibModel, float flLifetime );
  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. };
  82. class CRagGib : public CBaseAnimating
  83. {
  84. public:
  85. DECLARE_CLASS( CRagGib, CBaseAnimating );
  86. void Spawn( const char *szModel, const Vector &vecOrigin, const Vector &vecForce, float flFadeTime );
  87. };
  88. #endif //GIB_H