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.

98 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ITEMS_H
  8. #define ITEMS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "entityoutput.h"
  13. #include "player_pickup.h"
  14. #include "vphysics/constraints.h"
  15. // Armor given by a battery
  16. #define MAX_NORMAL_BATTERY 100
  17. // Ammo counts given by ammo items
  18. #define SIZE_AMMO_PISTOL 20
  19. #define SIZE_AMMO_PISTOL_LARGE 100
  20. #define SIZE_AMMO_SMG1 45
  21. #define SIZE_AMMO_SMG1_LARGE 225
  22. #define SIZE_AMMO_AR2 20
  23. #define SIZE_AMMO_AR2_LARGE 100
  24. #define SIZE_AMMO_RPG_ROUND 1
  25. #define SIZE_AMMO_SMG1_GRENADE 1
  26. #define SIZE_AMMO_BUCKSHOT 20
  27. #define SIZE_AMMO_357 6
  28. #define SIZE_AMMO_357_LARGE 20
  29. #define SIZE_AMMO_CROSSBOW 6
  30. #define SIZE_AMMO_AR2_ALTFIRE 1
  31. #define SF_ITEM_START_CONSTRAINED 0x00000001
  32. class CItem : public CBaseAnimating, public CDefaultPlayerPickupVPhysics
  33. {
  34. public:
  35. DECLARE_CLASS( CItem, CBaseAnimating );
  36. CItem();
  37. virtual void Spawn( void );
  38. virtual void Precache();
  39. unsigned int PhysicsSolidMaskForEntity( void ) const;
  40. virtual CBaseEntity* Respawn( void );
  41. virtual void ItemTouch( CBaseEntity *pOther );
  42. virtual void Materialize( void );
  43. virtual bool MyTouch( CBasePlayer *pPlayer ) { return false; };
  44. // Become touchable when we are at rest
  45. virtual void OnEntityEvent( EntityEvent_t event, void *pEventData );
  46. // Activate when at rest, but don't allow pickup until then
  47. void ActivateWhenAtRest( float flTime = 0.5f );
  48. // IPlayerPickupVPhysics
  49. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON );
  50. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t reason );
  51. virtual int ObjectCaps() { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_WCEDIT_POSITION; };
  52. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  53. Vector GetOriginalSpawnOrigin( void ) { return m_vOriginalSpawnOrigin; }
  54. QAngle GetOriginalSpawnAngles( void ) { return m_vOriginalSpawnAngles; }
  55. void SetOriginalSpawnOrigin( const Vector& origin ) { m_vOriginalSpawnOrigin = origin; }
  56. void SetOriginalSpawnAngles( const QAngle& angles ) { m_vOriginalSpawnAngles = angles; }
  57. bool CreateItemVPhysicsObject( void );
  58. virtual bool ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer );
  59. #if defined( HL2MP ) || defined( TF_DLL )
  60. void FallThink( void );
  61. float m_flNextResetCheckTime;
  62. #endif
  63. DECLARE_DATADESC();
  64. protected:
  65. virtual void ComeToRest( void );
  66. bool m_bActivateWhenAtRest;
  67. private:
  68. COutputEvent m_OnPlayerTouch;
  69. COutputEvent m_OnCacheInteraction;
  70. Vector m_vOriginalSpawnOrigin;
  71. QAngle m_vOriginalSpawnAngles;
  72. IPhysicsConstraint *m_pConstraint;
  73. };
  74. #endif // ITEMS_H