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.

87 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. // Reasons behind a pickup
  12. enum PhysGunPickup_t
  13. {
  14. PICKED_UP_BY_CANNON,
  15. PUNTED_BY_CANNON,
  16. PICKED_UP_BY_PLAYER, // Picked up by +USE, not physgun.
  17. };
  18. // Reasons behind a drop
  19. enum PhysGunDrop_t
  20. {
  21. DROPPED_BY_PLAYER,
  22. THROWN_BY_PLAYER,
  23. DROPPED_BY_CANNON,
  24. LAUNCHED_BY_CANNON,
  25. };
  26. enum PhysGunForce_t
  27. {
  28. PHYSGUN_FORCE_DROPPED, // Dropped by +USE
  29. PHYSGUN_FORCE_THROWN, // Thrown from +USE
  30. PHYSGUN_FORCE_PUNTED, // Punted by cannon
  31. PHYSGUN_FORCE_LAUNCHED, // Launched by cannon
  32. };
  33. void PlayerPickupObject( CBasePlayer *pPlayer, CBaseEntity *pObject );
  34. void Pickup_ForcePlayerToDropThisObject( CBaseEntity *pTarget );
  35. void Pickup_OnPhysGunDrop( CBaseEntity *pDroppedObject, CBasePlayer *pPlayer, PhysGunDrop_t reason );
  36. void Pickup_OnPhysGunPickup( CBaseEntity *pPickedUpObject, CBasePlayer *pPlayer, PhysGunPickup_t reason = PICKED_UP_BY_CANNON );
  37. bool Pickup_OnAttemptPhysGunPickup( CBaseEntity *pPickedUpObject, CBasePlayer *pPlayer, PhysGunPickup_t reason = PICKED_UP_BY_CANNON );
  38. bool Pickup_GetPreferredCarryAngles( CBaseEntity *pObject, CBasePlayer *pPlayer, matrix3x4_t &localToWorld, QAngle &outputAnglesWorldSpace );
  39. bool Pickup_ForcePhysGunOpen( CBaseEntity *pObject, CBasePlayer *pPlayer );
  40. bool Pickup_ShouldPuntUseLaunchForces( CBaseEntity *pObject, PhysGunForce_t reason );
  41. AngularImpulse Pickup_PhysGunLaunchAngularImpulse( CBaseEntity *pObject, PhysGunForce_t reason );
  42. Vector Pickup_DefaultPhysGunLaunchVelocity( const Vector &vecForward, float flMass );
  43. Vector Pickup_PhysGunLaunchVelocity( CBaseEntity *pObject, const Vector &vecForward, PhysGunForce_t reason );
  44. CBaseEntity *Pickup_OnFailedPhysGunPickup( CBaseEntity *pPickedUpObject, Vector vPhysgunPos );
  45. abstract_class IPlayerPickupVPhysics
  46. {
  47. public:
  48. // Callbacks for the physgun/cannon picking up an entity
  49. virtual bool OnAttemptPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) = 0;
  50. virtual CBaseEntity *OnFailedPhysGunPickup( Vector vPhysgunPos ) = 0;
  51. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) = 0;
  52. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason ) = 0;
  53. virtual bool HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer = NULL ) = 0;
  54. virtual QAngle PreferredCarryAngles( void ) = 0;
  55. virtual bool ForcePhysgunOpen( CBasePlayer *pPlayer ) = 0;
  56. virtual AngularImpulse PhysGunLaunchAngularImpulse() = 0;
  57. virtual bool ShouldPuntUseLaunchForces( PhysGunForce_t reason ) = 0;
  58. virtual Vector PhysGunLaunchVelocity( const Vector &vecForward, float flMass ) = 0;
  59. };
  60. class CDefaultPlayerPickupVPhysics : public IPlayerPickupVPhysics
  61. {
  62. public:
  63. virtual bool OnAttemptPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) { return true; }
  64. virtual CBaseEntity *OnFailedPhysGunPickup( Vector vPhysgunPos ) { return NULL; }
  65. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON ) {}
  66. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t reason ) {}
  67. virtual bool HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer ) { return false; }
  68. virtual QAngle PreferredCarryAngles( void ) { return vec3_angle; }
  69. virtual bool ForcePhysgunOpen( CBasePlayer *pPlayer ) { return false; }
  70. virtual AngularImpulse PhysGunLaunchAngularImpulse() { return RandomAngularImpulse( -600, 600 ); }
  71. virtual bool ShouldPuntUseLaunchForces( PhysGunForce_t reason ) { return false; }
  72. virtual Vector PhysGunLaunchVelocity( const Vector &vecForward, float flMass )
  73. {
  74. return Pickup_DefaultPhysGunLaunchVelocity( vecForward, flMass );
  75. }
  76. };
  77. #endif // PLAYER_PICKUP_H