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.

93 lines
4.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: APIs for player pickup of physics objects
  4. //
  5. //=============================================================================//
  6. #ifndef PLAYER_PICKUP_H
  7. #define PLAYER_PICKUP_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #ifdef HL2_DLL
  12. // Needed for launch velocity
  13. extern ConVar physcannon_minforce;
  14. extern ConVar physcannon_maxforce;
  15. #endif
  16. // Reasons behind a pickup
  17. enum PhysGunPickup_t
  18. {
  19. PICKED_UP_BY_CANNON,
  20. PUNTED_BY_CANNON,
  21. PICKED_UP_BY_PLAYER, // Picked up by +USE, not physgun.
  22. };
  23. // Reasons behind a drop
  24. enum PhysGunDrop_t
  25. {
  26. DROPPED_BY_PLAYER,
  27. THROWN_BY_PLAYER,
  28. DROPPED_BY_CANNON,
  29. LAUNCHED_BY_CANNON,
  30. };
  31. enum PhysGunForce_t
  32. {
  33. PHYSGUN_FORCE_DROPPED, // Dropped by +USE
  34. PHYSGUN_FORCE_THROWN, // Thrown from +USE
  35. PHYSGUN_FORCE_PUNTED, // Punted by cannon
  36. PHYSGUN_FORCE_LAUNCHED, // Launched by cannon
  37. };
  38. void PlayerPickupObject( CBasePlayer *pPlayer, CBaseEntity *pObject );
  39. void Pickup_ForcePlayerToDropThisObject( CBaseEntity *pTarget );
  40. void Pickup_OnPhysGunDrop( CBaseEntity *pDroppedObject, CBasePlayer *pPlayer, PhysGunDrop_t reason );
  41. void Pickup_OnPhysGunPickup( CBaseEntity *pPickedUpObject, CBasePlayer *pPlayer, PhysGunPickup_t reason = PICKED_UP_BY_CANNON );
  42. bool Pickup_OnAttemptPhysGunPickup( CBaseEntity *pPickedUpObject, CBasePlayer *pPlayer, PhysGunPickup_t reason = PICKED_UP_BY_CANNON );
  43. bool Pickup_GetPreferredCarryAngles( CBaseEntity *pObject, CBasePlayer *pPlayer, matrix3x4_t &localToWorld, QAngle &outputAnglesWorldSpace );
  44. bool Pickup_ForcePhysGunOpen( CBaseEntity *pObject, CBasePlayer *pPlayer );
  45. bool Pickup_ShouldPuntUseLaunchForces( CBaseEntity *pObject, PhysGunForce_t reason );
  46. AngularImpulse Pickup_PhysGunLaunchAngularImpulse( CBaseEntity *pObject, PhysGunForce_t reason );
  47. Vector Pickup_DefaultPhysGunLaunchVelocity( const Vector &vecForward, float flMass );
  48. Vector Pickup_PhysGunLaunchVelocity( CBaseEntity *pObject, const Vector &vecForward, PhysGunForce_t reason );
  49. CBaseEntity *Pickup_OnFailedPhysGunPickup( CBaseEntity *pPickedUpObject, Vector vPhysgunPos );
  50. abstract_class IPlayerPickupVPhysics
  51. {
  52. public:
  53. // Callbacks for the physgun/cannon picking up an entity
  54. virtual bool OnAttemptPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) = 0;
  55. virtual CBaseEntity *OnFailedPhysGunPickup( Vector vPhysgunPos ) = 0;
  56. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) = 0;
  57. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason ) = 0;
  58. virtual bool HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer = NULL ) = 0;
  59. virtual QAngle PreferredCarryAngles( void ) = 0;
  60. virtual bool ForcePhysgunOpen( CBasePlayer *pPlayer ) = 0;
  61. virtual AngularImpulse PhysGunLaunchAngularImpulse() = 0;
  62. virtual bool ShouldPuntUseLaunchForces( PhysGunForce_t reason ) = 0;
  63. virtual Vector PhysGunLaunchVelocity( const Vector &vecForward, float flMass ) = 0;
  64. };
  65. class CDefaultPlayerPickupVPhysics : public IPlayerPickupVPhysics
  66. {
  67. public:
  68. virtual bool OnAttemptPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) { return true; }
  69. virtual CBaseEntity *OnFailedPhysGunPickup( Vector vPhysgunPos ) { return NULL; }
  70. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) {}
  71. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t reason ) {}
  72. virtual bool HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer ) { return false; }
  73. virtual QAngle PreferredCarryAngles( void ) { return vec3_angle; }
  74. virtual bool ForcePhysgunOpen( CBasePlayer *pPlayer ) { return false; }
  75. virtual AngularImpulse PhysGunLaunchAngularImpulse() { return RandomAngularImpulse( -600, 600 ); }
  76. virtual bool ShouldPuntUseLaunchForces( PhysGunForce_t reason ) { return false; }
  77. virtual Vector PhysGunLaunchVelocity( const Vector &vecForward, float flMass )
  78. {
  79. return Pickup_DefaultPhysGunLaunchVelocity( vecForward, flMass );
  80. }
  81. };
  82. #endif // PLAYER_PICKUP_H