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.

98 lines
3.0 KiB

  1. //========= Copyright � 1996-2005, 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 SIZE_AMMO_FLECHETTE 60
  32. #define SIZE_AMMO_URANIUM 30
  33. #define SF_ITEM_START_CONSTRAINED 0x00000001
  34. #define SF_ITEM_MUST_EXIST 0x00000002 // prevent the procedural population system from modifying this item
  35. class CItem : public CBaseAnimating, public CDefaultPlayerPickupVPhysics
  36. {
  37. public:
  38. DECLARE_CLASS( CItem, CBaseAnimating );
  39. CItem();
  40. virtual ~CItem();
  41. virtual void Spawn( void );
  42. virtual void Precache();
  43. virtual bool HasBloatedCollision( void ) const { return true; } // Does this item increase its collision box to make it easier to pick up?
  44. virtual CBaseEntity* Respawn( void );
  45. void ItemTouch( CBaseEntity *pOther );
  46. void ItemForceTouch( CBaseEntity *pOther );
  47. virtual void Materialize( void );
  48. virtual bool MyTouch( CBasePlayer *pPlayer ) { return false; };
  49. // Become touchable when we are at rest
  50. virtual void OnEntityEvent( EntityEvent_t event, void *pEventData );
  51. // Activate when at rest, but don't allow pickup until then
  52. void ActivateWhenAtRest( float flTime = 0.5f );
  53. // IPlayerPickupVPhysics
  54. virtual void OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason = PICKED_UP_BY_CANNON );
  55. virtual void OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t reason );
  56. virtual int ObjectCaps() { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_WCEDIT_POSITION; };
  57. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  58. Vector GetOriginalSpawnOrigin( void ) { return m_vOriginalSpawnOrigin; }
  59. QAngle GetOriginalSpawnAngles( void ) { return m_vOriginalSpawnAngles; }
  60. void SetOriginalSpawnOrigin( const Vector& origin ) { m_vOriginalSpawnOrigin = origin; }
  61. void SetOriginalSpawnAngles( const QAngle& angles ) { m_vOriginalSpawnAngles = angles; }
  62. bool CreateItemVPhysicsObject( void );
  63. virtual bool ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer );
  64. DECLARE_DATADESC();
  65. private:
  66. void ComeToRest( void );
  67. void ItemTouchInternal( CBaseEntity *pOther, bool bForceTouch );
  68. private:
  69. bool m_bActivateWhenAtRest;
  70. COutputEvent m_OnPlayerTouch;
  71. COutputEvent m_OnCacheInteraction;
  72. Vector m_vOriginalSpawnOrigin;
  73. QAngle m_vOriginalSpawnAngles;
  74. IPhysicsConstraint *m_pConstraint;
  75. };
  76. #endif // ITEMS_H