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.

250 lines
7.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PHYSOBJ_H
  8. #define PHYSOBJ_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #ifndef PHYSICS_H
  13. #include "physics.h"
  14. #endif
  15. #include "entityoutput.h"
  16. #include "func_break.h"
  17. #include "player_pickup.h"
  18. // ---------------------------------------------------------------------
  19. //
  20. // CPhysBox -- physically simulated brush rectangular solid
  21. //
  22. // ---------------------------------------------------------------------
  23. // Physbox Spawnflags. Start at 0x01000 to avoid collision with CBreakable's
  24. #define SF_PHYSBOX_ASLEEP 0x01000
  25. #define SF_PHYSBOX_IGNOREUSE 0x02000
  26. #define SF_PHYSBOX_DEBRIS 0x04000
  27. #define SF_PHYSBOX_MOTIONDISABLED 0x08000
  28. #define SF_PHYSBOX_USEPREFERRED 0x10000
  29. #define SF_PHYSBOX_ENABLE_ON_PHYSCANNON 0x20000
  30. #define SF_PHYSBOX_NO_ROTORWASH_PUSH 0x40000 // The rotorwash doesn't push these
  31. #define SF_PHYSBOX_ENABLE_PICKUP_OUTPUT 0x80000
  32. #define SF_PHYSBOX_ALWAYS_PICK_UP 0x100000 // Physcannon can always pick this up, no matter what mass or constraints may apply.
  33. #define SF_PHYSBOX_NEVER_PICK_UP 0x200000 // Physcannon will never be able to pick this up.
  34. #define SF_PHYSBOX_NEVER_PUNT 0x400000 // Physcannon will never be able to punt this object.
  35. #define SF_PHYSBOX_PREVENT_PLAYER_TOUCH_ENABLE 0x800000 // If set, the player will not cause the object to enable its motion when bumped into
  36. // UNDONE: Hook collisions into the physics system to generate touch functions and take damage on falls
  37. // UNDONE: Base class PhysBrush
  38. class CPhysBox : public CBreakable
  39. {
  40. DECLARE_CLASS( CPhysBox, CBreakable );
  41. public:
  42. DECLARE_SERVERCLASS();
  43. void Spawn ( void );
  44. bool CreateVPhysics();
  45. void Move( const Vector &force );
  46. virtual int ObjectCaps();
  47. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  48. virtual int DrawDebugTextOverlays(void);
  49. virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
  50. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );
  51. int OnTakeDamage( const CTakeDamageInfo &info );
  52. void EnableMotion( void );
  53. bool CanBePickedUpByPhyscannon();
  54. // IPlayerPickupVPhysics
  55. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason );
  56. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason );
  57. bool HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer );
  58. virtual QAngle PreferredCarryAngles( void ) { return m_angPreferredCarryAngles; }
  59. int ExploitableByPlayer() const { return m_iExploitableByPlayer; }
  60. // inputs
  61. void InputWake( inputdata_t &inputdata );
  62. void InputSleep( inputdata_t &inputdata );
  63. void InputEnableMotion( inputdata_t &inputdata );
  64. void InputDisableMotion( inputdata_t &inputdata );
  65. void InputEnable( inputdata_t &inputdata );
  66. void InputDisable( inputdata_t &inputdata );
  67. void InputForceDrop( inputdata_t &inputdata );
  68. void InputDisableFloating( inputdata_t &inputdata );
  69. void InputBecomeDebris( inputdata_t &inputdata );
  70. DECLARE_DATADESC();
  71. protected:
  72. int m_damageType;
  73. float m_massScale;
  74. string_t m_iszOverrideScript;
  75. int m_damageToEnableMotion;
  76. float m_flForceToEnableMotion;
  77. QAngle m_angPreferredCarryAngles;
  78. bool m_bNotSolidToWorld;
  79. int m_iExploitableByPlayer;
  80. // Outputs
  81. COutputEvent m_OnDamaged;
  82. COutputEvent m_OnAwakened;
  83. COutputEvent m_OnMotionEnabled;
  84. COutputEvent m_OnPhysGunPickup;
  85. COutputEvent m_OnPhysGunPunt;
  86. COutputEvent m_OnPhysGunOnlyPickup;
  87. COutputEvent m_OnPhysGunDrop;
  88. COutputEvent m_OnPlayerUse;
  89. CHandle<CBasePlayer> m_hCarryingPlayer; // Player who's carrying us
  90. };
  91. // ---------------------------------------------------------------------
  92. //
  93. // CPhysExplosion -- physically simulated explosion
  94. //
  95. // ---------------------------------------------------------------------
  96. #define SF_PHYSEXPLOSION_NODAMAGE 0x0001
  97. #define SF_PHYSEXPLOSION_PUSH_PLAYER 0x0002
  98. #define SF_PHYSEXPLOSION_RADIAL 0x0004
  99. #define SF_PHYSEXPLOSION_TEST_LOS 0x0008
  100. #define SF_PHYSEXPLOSION_DISORIENT_PLAYER 0x0010
  101. class CPhysExplosion : public CPointEntity
  102. {
  103. public:
  104. DECLARE_CLASS( CPhysExplosion, CPointEntity );
  105. void Spawn ( void );
  106. void Explode( CBaseEntity *pActivator, CBaseEntity *pCaller );
  107. void ExplodeAndRemove( CBaseEntity *pActivator, CBaseEntity *pCaller );
  108. CBaseEntity *FindEntity( CBaseEntity *pEntity, CBaseEntity *pActivator, CBaseEntity *pCaller );
  109. int DrawDebugTextOverlays(void);
  110. // Input handlers
  111. void InputExplode( inputdata_t &inputdata );
  112. void InputExplodeAndRemove( inputdata_t &inputdata );
  113. DECLARE_DATADESC();
  114. float GetRadius( void );
  115. float m_damage;
  116. float m_radius;
  117. string_t m_targetEntityName;
  118. float m_flInnerRadius;
  119. COutputEvent m_OnPushedPlayer;
  120. };
  121. void CreatePhysExplosion( Vector origin, float magnitude, float radius, string_t target, float innerRadius, int flags );
  122. //==================================================
  123. // CPhysImpact
  124. //==================================================
  125. class CPhysImpact : public CPointEntity
  126. {
  127. public:
  128. DECLARE_CLASS( CPhysImpact, CPointEntity );
  129. void Spawn( void );
  130. //void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  131. void Activate( void );
  132. void InputImpact( inputdata_t &inputdata );
  133. DECLARE_DATADESC();
  134. private:
  135. void PointAtEntity( void );
  136. float m_damage;
  137. float m_distance;
  138. string_t m_directionEntityName;
  139. };
  140. //-----------------------------------------------------------------------------
  141. // Purpose: A magnet that creates constraints between itself and anything it touches
  142. //-----------------------------------------------------------------------------
  143. struct magnetted_objects_t
  144. {
  145. IPhysicsConstraint *pConstraint;
  146. EHANDLE hEntity;
  147. DECLARE_SIMPLE_DATADESC();
  148. };
  149. class CPhysMagnet : public CBaseAnimating, public IPhysicsConstraintEvent
  150. {
  151. DECLARE_CLASS( CPhysMagnet, CBaseAnimating );
  152. public:
  153. DECLARE_DATADESC();
  154. DECLARE_SERVERCLASS();
  155. CPhysMagnet();
  156. ~CPhysMagnet();
  157. void Spawn( void );
  158. void Precache( void );
  159. void Touch( CBaseEntity *pOther );
  160. void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );
  161. void DoMagnetSuck( CBaseEntity *pOther );
  162. void SetConstraintGroup( IPhysicsConstraintGroup *pGroup );
  163. bool IsOn( void ) { return m_bActive; }
  164. int GetNumAttachedObjects( void );
  165. float GetTotalMassAttachedObjects( void );
  166. CBaseEntity *GetAttachedObject( int iIndex );
  167. // Checking for hitting something
  168. void ResetHasHitSomething( void ) { m_bHasHitSomething = false; }
  169. bool HasHitSomething( void ) { return m_bHasHitSomething; }
  170. // Inputs
  171. void InputToggle( inputdata_t &inputdata );
  172. void InputTurnOn( inputdata_t &inputdata );
  173. void InputTurnOff( inputdata_t &inputdata );
  174. void InputConstraintBroken( inputdata_t &inputdata );
  175. void DetachAll( void );
  176. // IPhysicsConstraintEvent
  177. public:
  178. void ConstraintBroken( IPhysicsConstraint *pConstraint );
  179. protected:
  180. // Outputs
  181. COutputEvent m_OnMagnetAttach;
  182. COutputEvent m_OnMagnetDetach;
  183. // Keys
  184. float m_massScale;
  185. string_t m_iszOverrideScript;
  186. float m_forceLimit;
  187. float m_torqueLimit;
  188. CUtlVector< magnetted_objects_t > m_MagnettedEntities;
  189. IPhysicsConstraintGroup *m_pConstraintGroup;
  190. bool m_bActive;
  191. bool m_bHasHitSomething;
  192. float m_flTotalMass;
  193. float m_flRadius;
  194. float m_flNextSuckTime;
  195. int m_iMaxObjectsAttached;
  196. };
  197. #endif // PHYSOBJ_H