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.

163 lines
6.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef PHYSICS_PROP_RAGDOLL_H
  7. #define PHYSICS_PROP_RAGDOLL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "ragdoll_shared.h"
  12. #include "player_pickup.h"
  13. namespace ResponseRules { class IResponseSystem; };
  14. //-----------------------------------------------------------------------------
  15. // Purpose: entity class for simple ragdoll physics
  16. //-----------------------------------------------------------------------------
  17. // UNDONE: Move this to a private header
  18. class CRagdollProp : public CBaseAnimating, public CDefaultPlayerPickupVPhysics
  19. {
  20. DECLARE_CLASS( CRagdollProp, CBaseAnimating );
  21. public:
  22. CRagdollProp( void );
  23. ~CRagdollProp( void );
  24. virtual void UpdateOnRemove( void );
  25. void DrawDebugGeometryOverlays();
  26. void Spawn( void );
  27. void Precache( void );
  28. // Disable auto fading under dx7 or when level fades are specified
  29. void DisableAutoFade();
  30. int ObjectCaps();
  31. DECLARE_SERVERCLASS();
  32. // Don't treat as a live target
  33. virtual bool IsAlive( void ) { return false; }
  34. virtual void TraceAttack( const CTakeDamageInfo &info, const Vector &dir, trace_t *ptr );
  35. virtual bool TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace );
  36. virtual void Teleport( const Vector *newPosition, const QAngle *newAngles, const Vector *newVelocity, bool bUseSlowHighAccuracyContacts );
  37. virtual void SetupBones( matrix3x4a_t *pBoneToWorld, int boneMask );
  38. virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
  39. virtual int VPhysicsGetObjectList( IPhysicsObject **pList, int listMax );
  40. virtual int DrawDebugTextOverlays(void);
  41. // Response system stuff
  42. virtual ResponseRules::IResponseSystem *GetResponseSystem();
  43. virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set );
  44. void SetSourceClassName( const char *pClassname );
  45. // Physics attacker
  46. virtual CBasePlayer *HasPhysicsAttacker( float dt );
  47. // locals
  48. void InitRagdollAnimation( void );
  49. void InitRagdoll( const Vector &forceVector, int forceBone, const Vector &forcePos, matrix3x4_t *pPrevBones, matrix3x4_t *pBoneToWorld, float dt, int collisionGroup, bool activateRagdoll, bool bWakeRagdoll = true );
  50. void RecheckCollisionFilter( void );
  51. void SetDebrisThink();
  52. void ClearFlagsThink( void );
  53. inline ragdoll_t *GetRagdoll( void ) { return &m_ragdoll; }
  54. virtual bool IsRagdoll() { return true; }
  55. // Damage passing
  56. virtual void SetDamageEntity( CBaseEntity *pEntity );
  57. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  58. virtual void OnSave( IEntitySaveUtils *pUtils );
  59. virtual void OnRestore();
  60. // Purpose: CDefaultPlayerPickupVPhysics
  61. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );
  62. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason );
  63. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason );
  64. virtual AngularImpulse PhysGunLaunchAngularImpulse();
  65. bool HasPhysgunInteraction( const char *pszKeyName, const char *pszValue );
  66. void HandleFirstCollisionInteractions( int index, gamevcollisionevent_t *pEvent );
  67. void SetUnragdoll( CBaseAnimating *pOther );
  68. void SetBlendWeight( float weight ) { m_flBlendWeight = weight; }
  69. void SetOverlaySequence( Activity activity );
  70. void FadeOut( float flDelay = 0, float fadeTime = -1 );
  71. bool IsFading();
  72. CBaseEntity* GetKiller() { return m_hKiller; }
  73. void SetKiller( CBaseEntity *pKiller ) { m_hKiller = pKiller; }
  74. void GetAngleOverrideFromCurrentState( char *pOut, int size );
  75. void DisableMotion( void );
  76. // Input/Output
  77. void InputStartRadgollBoogie( inputdata_t &inputdata );
  78. void InputEnableMotion( inputdata_t &inputdata );
  79. void InputDisableMotion( inputdata_t &inputdata );
  80. void InputTurnOn( inputdata_t &inputdata );
  81. void InputTurnOff( inputdata_t &inputdata );
  82. void InputFadeAndRemove( inputdata_t &inputdata );
  83. DECLARE_DATADESC();
  84. protected:
  85. void CalcRagdollSize( void );
  86. ragdoll_t m_ragdoll;
  87. private:
  88. void UpdateNetworkDataFromVPhysics( IPhysicsObject *pPhysics, int index );
  89. void FadeOutThink();
  90. bool m_bStartDisabled;
  91. CNetworkArray( Vector, m_ragPos, RAGDOLL_MAX_ELEMENTS );
  92. CNetworkArray( QAngle, m_ragAngles, RAGDOLL_MAX_ELEMENTS );
  93. string_t m_anglesOverrideString;
  94. typedef CHandle<CBaseAnimating> CBaseAnimatingHandle;
  95. CNetworkVar( CBaseAnimatingHandle, m_hUnragdoll );
  96. unsigned int m_lastUpdateTickCount;
  97. bool m_allAsleep;
  98. bool m_bFirstCollisionAfterLaunch;
  99. EHANDLE m_hDamageEntity;
  100. EHANDLE m_hKiller; // Who killed me?
  101. CHandle<CBasePlayer> m_hPhysicsAttacker;
  102. float m_flLastPhysicsInfluenceTime;
  103. float m_flFadeOutStartTime;
  104. float m_flFadeTime;
  105. string_t m_strSourceClassName;
  106. bool m_bHasBeenPhysgunned;
  107. // If not 1, then allow underlying sequence to blend in with simulated bone positions
  108. CNetworkVar( float, m_flBlendWeight );
  109. CNetworkVar( int, m_nOverlaySequence );
  110. float m_flDefaultFadeScale;
  111. Vector m_ragdollMins[RAGDOLL_MAX_ELEMENTS];
  112. Vector m_ragdollMaxs[RAGDOLL_MAX_ELEMENTS];
  113. };
  114. CBaseEntity *CreateServerRagdoll( CBaseAnimating *pAnimating, int forceBone, const CTakeDamageInfo &info, int collisionGroup, bool bUseLRURetirement = false );
  115. CRagdollProp *CreateServerRagdollAttached( CBaseAnimating *pAnimating, const Vector &vecForce, int forceBone, int collisionGroup, IPhysicsObject *pAttached, CBaseAnimating *pParentEntity, int boneAttach, const Vector &originAttached, int parentBoneAttach, const Vector &boneOrigin );
  116. void DetachAttachedRagdoll( CBaseEntity *pRagdollIn );
  117. void DetachAttachedRagdollsForEntity( CBaseEntity *pRagdollParent );
  118. CBaseAnimating *CreateServerRagdollSubmodel( CBaseAnimating *pOwner, const char *pModelName, const Vector &position, const QAngle &angles, int collisionGroup );
  119. bool Ragdoll_IsPropRagdoll( CBaseEntity *pEntity );
  120. void Ragdoll_GetAngleOverrideString( char *pOut, int size, CBaseEntity *pEntity );
  121. ragdoll_t *Ragdoll_GetRagdoll( CBaseEntity *pEntity );
  122. #endif // PHYSICS_PROP_RAGDOLL_H