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.

206 lines
7.4 KiB

  1. //========= Copyright � 1996-2003, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ECON_ENTITY_H
  7. #define ECON_ENTITY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <utlsortvector.h>
  12. #include <utlhashtable.h>
  13. #include "ihasattributes.h"
  14. #include "ihasowner.h"
  15. #include "attribute_manager.h"
  16. #ifdef DOTA_DLL
  17. #include "dota_econ_item_string_table.h"
  18. #endif
  19. #if defined( CLIENT_DLL )
  20. #define CEconEntity C_EconEntity
  21. #define CBaseAttributableItem C_BaseAttributableItem
  22. #endif
  23. //-----------------------------------------------------------------------------
  24. // Purpose:
  25. //-----------------------------------------------------------------------------
  26. class CEconEntity : public CBaseFlex, public IHasAttributes
  27. {
  28. DECLARE_CLASS( CEconEntity, CBaseFlex );
  29. public:
  30. DECLARE_NETWORKCLASS();
  31. DECLARE_DATADESC();
  32. CEconEntity();
  33. ~CEconEntity();
  34. void InitializeAttributes( void );
  35. void DebugDescribe( void );
  36. Activity TranslateViewmodelHandActivity( Activity actBase );
  37. virtual void UpdateOnRemove( void );
  38. virtual CStudioHdr * OnNewModel();
  39. bool HasCustomParticleSystems( void );
  40. #if !defined( CLIENT_DLL )
  41. virtual void GiveTo( CBaseEntity *pOther ) {}
  42. void OnOwnerClassChange( void );
  43. void UpdateModelToClass( void );
  44. void PlayAnimForPlaybackEvent( wearableanimplayback_t iPlayback );
  45. virtual int CalculateVisibleClassFor( CBaseCombatCharacter *pPlayer );
  46. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  47. #else
  48. virtual void SetDormant( bool bDormant );
  49. virtual void OnPreDataChanged( DataUpdateType_t type );
  50. virtual void OnDataChanged( DataUpdateType_t updateType );
  51. virtual bool ShouldShowToolTip( void ) { return true; }
  52. virtual bool InitializeAsClientEntity( const char *pszModelName, bool bRenderWithViewModels );
  53. virtual int InternalDrawModel( int flags, const RenderableInstance_t &instance );
  54. virtual bool OnInternalDrawModel( ClientModelRenderInfo_t *pInfo );
  55. virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
  56. virtual bool OnFireEvent( C_BaseViewModel *pViewModel, const Vector& origin, const QAngle& angles, int event, const char *options );
  57. bool InternalFireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
  58. // Custom flex controllers
  59. virtual bool UsesFlexDelayedWeights( void );
  60. virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
  61. float m_flFlexDelayTime;
  62. float * m_flFlexDelayedWeight;
  63. // Custom particle attachments
  64. void UpdateParticleSystems( void );
  65. virtual bool ShouldDrawParticleSystems( void );
  66. void SetParticleSystemsVisible( bool bVisible );
  67. void UpdateSingleParticleSystem( bool bVisible, attachedparticlesystem_t *pSystem, const char *pszAttachmentName = NULL );
  68. virtual void UpdateAttachmentModels( void );
  69. virtual bool AttachmentModelsShouldBeVisible( void ) { return true; }
  70. // Viewmodel overriding
  71. virtual bool ViewModel_IsTransparent( void );
  72. virtual bool ViewModel_IsUsingFBTexture( void );
  73. virtual bool IsOverridingViewmodel( void );
  74. virtual int DrawOverriddenViewmodel( C_BaseViewModel *pViewmodel, int flags );
  75. // Attachments
  76. bool WantsToOverrideViewmodelAttachments( void ) { return (m_hViewmodelAttachment != nullptr); }
  77. virtual int LookupAttachment( const char *pAttachmentName );
  78. virtual bool GetAttachment( const char *szName, Vector &absOrigin ) { return BaseClass::GetAttachment(szName,absOrigin); }
  79. virtual bool GetAttachment( const char *szName, Vector &absOrigin, QAngle &absAngles ) { return BaseClass::GetAttachment(szName,absOrigin,absAngles); }
  80. virtual bool GetAttachment( int number, matrix3x4_t &matrix );
  81. virtual bool GetAttachment( int number, Vector &origin );
  82. virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
  83. virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
  84. C_BaseAnimating *GetViewmodelAttachment( void ) { return m_hViewmodelAttachment.Get(); }
  85. virtual void ViewModelAttachmentBlending( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask ) {}
  86. void SetWaitingToLoad( bool bWaiting );
  87. virtual bool ValidateEntityAttachedToPlayer( bool &bShouldRetry );
  88. virtual void SetMaterialOverride( const char *pszMaterial );
  89. virtual void SetMaterialOverride( CMaterialReference &ref );
  90. bool m_bAttributesInitialized;
  91. #endif
  92. public:
  93. // IHasAttributes
  94. CAttributeManager *GetAttributeManager( void ) { return m_AttributeManager.Get(); }
  95. CAttributeContainer *GetAttributeContainer( void ) { return m_AttributeManager.Get(); }
  96. const CAttributeContainer *GetAttributeContainer( void ) const { return m_AttributeManager.Get(); }
  97. CBaseEntity *GetAttributeOwner( void ) { return GetOwnerEntity(); }
  98. CAttributeList *GetAttributeList( void ) { return m_AttributeManager.GetItem()->GetAttributeList(); }
  99. loadout_positions_t GetLoadoutPosition( int iTeam = 0 ) const;
  100. const CEconItemView* GetEconItemView( void ) const;
  101. virtual void SetOriginalOwnerXuid( uint32 nLow, uint32 nHigh ) { m_OriginalOwnerXuidLow = nLow; m_OriginalOwnerXuidHigh = nHigh; }
  102. virtual uint64 GetOriginalOwnerXuid( void ) const;
  103. // Obsolete, but used for demo backward compat
  104. virtual int GetFallbackPaintKit( void ) const { return m_nFallbackPaintKit; }
  105. virtual int GetFallbackSeed( void ) const { return m_nFallbackSeed; }
  106. virtual int GetFallbackWear( void ) const { return m_flFallbackWear; }
  107. virtual int GetFallbackStatTrak( void ) const { return m_nFallbackStatTrak; }
  108. virtual void ReapplyProvision( void );
  109. virtual bool UpdateBodygroups( CBaseCombatCharacter* pOwner, int iState );
  110. protected:
  111. virtual Activity TranslateViewmodelHandActivityInternal( Activity actBase ) { return actBase; }
  112. protected:
  113. CNetworkVarEmbedded( CAttributeContainer, m_AttributeManager );
  114. CNetworkVar( uint32, m_OriginalOwnerXuidLow );
  115. CNetworkVar( uint32, m_OriginalOwnerXuidHigh );
  116. // Obsolete, but used for demo backward compat
  117. CNetworkVar( int, m_nFallbackPaintKit );
  118. CNetworkVar( int, m_nFallbackSeed );
  119. CNetworkVar( float, m_flFallbackWear );
  120. CNetworkVar( int, m_nFallbackStatTrak );
  121. #ifdef CLIENT_DLL
  122. bool m_bClientside;
  123. bool m_bParticleSystemsCreated;
  124. CUtlVector<int> m_vecAttachedParticles;
  125. CMaterialReference m_MaterialOverrides;
  126. CHandle<C_BaseAnimating> m_hViewmodelAttachment;
  127. int m_iOldTeam;
  128. bool m_bAttachmentDirty;
  129. int m_nUnloadedModelIndex;
  130. int m_iNumOwnerValidationRetries;
  131. #endif
  132. EHANDLE m_hOldProvidee;
  133. #ifdef GAME_DLL
  134. int m_iOldOwnerClass; // Used to detect class changes on items that have per-class models
  135. #endif
  136. protected:
  137. #ifdef CLIENT_DLL
  138. public:
  139. // Additional attachments.
  140. struct AttachedModelData_t
  141. {
  142. const model_t *m_pModel;
  143. int m_iModelDisplayFlags;
  144. };
  145. CUtlVector<AttachedModelData_t> m_vecAttachedModels;
  146. #endif // CLIENT_DLL
  147. };
  148. #define ITEM_PICKUP_BOX_BLOAT 24
  149. #define VIEWMODEL_CLASS_RESTRICTION_DEFAULT_NONE -1
  150. //-----------------------------------------------------------------------------
  151. // Purpose:
  152. //-----------------------------------------------------------------------------
  153. class CBaseAttributableItem : public CEconEntity
  154. {
  155. DECLARE_CLASS( CBaseAttributableItem, CBaseAnimating );
  156. public:
  157. DECLARE_NETWORKCLASS();
  158. DECLARE_DATADESC();
  159. CBaseAttributableItem();
  160. };
  161. #endif // ECON_ENTITY_H