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.

137 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ECON_WEARABLE_H
  7. #define ECON_WEARABLE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "econ_entity.h"
  12. enum
  13. {
  14. MAX_WEARABLES_SENT_FROM_SERVER =
  15. #ifdef LOADOUT_MAX_WEARABLES_COUNT // we actually do want to just check for macro definition here -- undefined means "fall back to whatever default"
  16. LOADOUT_MAX_WEARABLES_COUNT
  17. #else
  18. 8 // hard-coded constant to match old behavior
  19. #endif
  20. };
  21. #if defined( CLIENT_DLL )
  22. #define CEconWearable C_EconWearable
  23. #define CTFWearableItem C_TFWearableItem
  24. #endif
  25. enum
  26. {
  27. ITEM_DROP_TYPE_NULL,
  28. ITEM_DROP_TYPE_NONE,
  29. ITEM_DROP_TYPE_DROP,
  30. ITEM_DROP_TYPE_BREAK,
  31. };
  32. class CEconWearable : public CEconEntity
  33. {
  34. DECLARE_CLASS( CEconWearable, CEconEntity );
  35. public:
  36. DECLARE_NETWORKCLASS();
  37. DECLARE_DATADESC();
  38. CEconWearable();
  39. virtual bool IsWearable( void ) const { return true; }
  40. // Shared
  41. virtual void Spawn( void );
  42. virtual void GiveTo( CBaseEntity *pOther );
  43. virtual void RemoveFrom( CBaseEntity *pOther );
  44. virtual bool CanEquip( CBaseEntity *pOther ) { return true; }
  45. virtual void Equip( CBasePlayer *pOwner );
  46. virtual void UnEquip( CBasePlayer* pOwner );
  47. virtual void OnWearerDeath( void );
  48. virtual int GetDropType( void );
  49. // virtual bool UpdateBodygroups( CBasePlayer* pOwner, int iState );
  50. void SetAlwaysAllow( bool bVal ) { m_bAlwaysAllow = bVal; }
  51. bool AlwaysAllow( void ) { return m_bAlwaysAllow; }
  52. virtual bool IsViewModelWearable( void ) { return false; }
  53. // Server
  54. #if defined( GAME_DLL )
  55. #endif
  56. // Client
  57. #if defined( CLIENT_DLL )
  58. virtual ShadowType_t ShadowCastType() OVERRIDE;
  59. virtual bool ShouldDraw();
  60. virtual bool ShouldDrawWhenPlayerIsDead() { return true; }
  61. virtual void OnDataChanged( DataUpdateType_t updateType );
  62. virtual void ClientThink( void );
  63. virtual bool ShouldDrawParticleSystems( void );
  64. virtual RenderGroup_t GetRenderGroup();
  65. #endif
  66. virtual int GetSkin( void );
  67. // Static
  68. static void UpdateWearableBodyGroups( CBasePlayer *pPlayer );
  69. protected:
  70. virtual void InternalSetPlayerDisplayModel( void );
  71. private:
  72. bool m_bAlwaysAllow; // Wearable will not be removed by ManageRegularWeapons. Only use this for wearables managed by other items!
  73. };
  74. //-----------------------------------------------------------------------------
  75. // Purpose: For backwards compatibility with older demos
  76. //-----------------------------------------------------------------------------
  77. class CTFWearableItem : public CEconWearable
  78. {
  79. DECLARE_CLASS( CTFWearableItem, CEconWearable );
  80. public:
  81. DECLARE_NETWORKCLASS();
  82. DECLARE_DATADESC();
  83. CTFWearableItem();
  84. };
  85. #ifdef CLIENT_DLL
  86. // Clientside wearable physics props. Used to have wearables fall off dying players.
  87. class C_EconWearableGib : public CEconEntity
  88. {
  89. DECLARE_CLASS( C_EconWearableGib, CEconEntity );
  90. public:
  91. C_EconWearableGib();
  92. ~C_EconWearableGib();
  93. bool Initialize( bool bWillBeParented );
  94. bool FinishModelInitialization( void );
  95. virtual CStudioHdr *OnNewModel( void );
  96. virtual bool ValidateEntityAttachedToPlayer( bool &bShouldRetry );
  97. virtual void SpawnClientEntity();
  98. virtual void Spawn();
  99. virtual void ClientThink( void );
  100. void StartFadeOut( float fDelay );
  101. virtual void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName );
  102. virtual CollideType_t GetCollideType( void ) { return ENTITY_SHOULD_RESPOND; }
  103. bool UpdateThinkState( void );
  104. private:
  105. bool m_bParented;
  106. bool m_bDelayedInit;
  107. float m_fDeathTime; // Point at which this object self destructs.
  108. // The default of -1 indicates the object shouldn't destruct.
  109. };
  110. #endif
  111. #endif // ECON_WEARABLE_H