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.

613 lines
24 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ECON_ITEM_CONSTANTS_H
  7. #define ECON_ITEM_CONSTANTS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "game_item_schema.h"
  12. #include "econ_item_constants.h"
  13. #include "localization_provider.h"
  14. #include "econ_item_interface.h"
  15. #include "econ_item.h"
  16. #include "tier1/utlhashtable.h"
  17. #if defined(CLIENT_DLL)
  18. #include "iclientrenderable.h"
  19. #if defined(CSTRIKE15)
  20. #include "materialsystem/custommaterialowner.h"
  21. #endif //#if defined(CSTRIKE15)
  22. #include "materialsystem/icompositetexturegenerator.h"
  23. #endif //#if defined(CLIENT_DLL)
  24. #include "materialsystem/MaterialSystemUtil.h"
  25. #if defined(TF_DLL)
  26. #include "tf_item_schema.h"
  27. #endif //#if defined(TF_DLL)
  28. #if defined(CLIENT_DLL)
  29. #define CEconItemView C_EconItemView
  30. #if defined(CSTRIKE15)
  31. typedef void (*ImageReadyCallback_t)( const CEconItemView *pItemView, CUtlBuffer &rawImageRgba, int nWidth, int nHeight, uint64 nItemID );
  32. struct RenderToRTData_t;
  33. class CMergedMDL;
  34. #endif //#if defined(CSTRIKE15)
  35. #endif //#if defined(CLIENT_DLL)
  36. #include "econ_item_view_helpers.h"
  37. #define RGB_INT_RED 12073019
  38. #define RGB_INT_BLUE 5801378
  39. #define ECON_ITEM_GENERATED_ICON_WIDTH 512
  40. #define ECON_ITEM_GENERATED_ICON_HEIGHT 384
  41. #define ECON_ITEM_GENERATED_PINBOARD_ICON_WIDTH 512
  42. #define ECON_ITEM_GENERATED_PINBOARD_ICON_HEIGHT 384
  43. #define ECON_ITEM_GENERATED_ICON_DIR "resource/Flash/econ/weapons/cached/"
  44. #define SCHEMA_BASE_ITEM_MAX 499 // def indices 1-499 are reserved for default aka stock items
  45. class CEconItemAttribute;
  46. class CAttributeManager;
  47. #if defined(CSTRIKE_CLIENT_DLL)
  48. class IVisualsDataProcessor;
  49. #endif
  50. struct stickerMaterialReference_t
  51. {
  52. CMaterialReference m_pMaterialReferenceFirstPerson;
  53. CMaterialReference m_pMaterialReferenceThirdPerson;
  54. int m_nSlotIndex;
  55. };
  56. //-----------------------------------------------------------------------------
  57. // Purpose:
  58. //-----------------------------------------------------------------------------
  59. class CAttributeList
  60. {
  61. friend class CEconItemView;
  62. friend class CTFPlayer;
  63. DECLARE_CLASS_NOBASE( CAttributeList );
  64. public:
  65. DECLARE_EMBEDDED_NETWORKVAR();
  66. DECLARE_DATADESC();
  67. CAttributeList();
  68. CAttributeList& operator=( const CAttributeList &src );
  69. void Init();
  70. void SetManager( CAttributeManager *pManager );
  71. void IterateAttributes( class IEconItemAttributeIterator *pIterator );
  72. // Remove all attributes on this item
  73. void DestroyAllAttributes( void );
  74. // Prevent clients from modifying attributes directly from this list. They should do it from the CEconItemView.
  75. private:
  76. // Add an attribute to this item
  77. void AddAttribute( CEconItemAttribute *pAttribute );
  78. void SetOrAddAttributeValueByName( const char *pszAttribDefName, float flValue );
  79. // Remove an attribute by name
  80. void RemoveAttribute( const char *pszAttribDefName );
  81. void RemoveAttributeByIndex( int iIndex );
  82. public:
  83. // Returns the attribute that matches the attribute defname
  84. CEconItemAttribute *GetAttributeByName( const char *pszAttribDefName );
  85. const CEconItemAttribute *GetAttributeByName( const char *pszAttribDefName ) const;
  86. // Returns the attribute matching the specified class, carried by this entity, if it exists.
  87. CEconItemAttribute *GetAttributeByClass( const char *szAttribClass );
  88. const CEconItemAttribute *GetAttributeByClass( const char *szAttribClass ) const;
  89. // Returns the attribute that matches the attribute defindex
  90. CEconItemAttribute *GetAttributeByDefIndex( uint16 unAttrDefIndex );
  91. const CEconItemAttribute *GetAttributeByDefIndex( uint16 unAttrDefIndex ) const;
  92. // The only way to set the value of an attribute after its creation is through the attribute list
  93. // that contains it. This way the matching attribute manager is told one of its attributes has changed.
  94. void SetValue( CEconItemAttribute *pAttrib, float flValue );
  95. void UpdateManagerCache( void );
  96. private:
  97. // Attribute accessing
  98. int GetNumAttributes( void ) const { return m_Attributes.Count(); }
  99. CEconItemAttribute *GetAttribute( int iIndex ) { Assert( iIndex >= 0 && iIndex < m_Attributes.Count()); return &m_Attributes[iIndex]; }
  100. const CEconItemAttribute *GetAttribute( int iIndex ) const { Assert( iIndex >= 0 && iIndex < m_Attributes.Count()); return &m_Attributes[iIndex]; }
  101. // Our list of attributes
  102. CUtlVector<CEconItemAttribute> m_Attributes;
  103. CAttributeManager *m_pManager;
  104. };
  105. //-----------------------------------------------------------------------------
  106. // Purpose: An attribute that knows how to read itself from a datafile, describe itself to the user,
  107. // and serialize itself between Servers, Clients, and Steam.
  108. // Unlike the attributes created in the Game DLL, this attribute doesn't know how to actually
  109. // do anything in the game, it just knows how to describe itself.
  110. //-----------------------------------------------------------------------------
  111. class CEconItemAttribute
  112. {
  113. DECLARE_CLASS_NOBASE( CEconItemAttribute );
  114. public:
  115. DECLARE_EMBEDDED_NETWORKVAR();
  116. CEconItemAttribute( const attrib_definition_index_t iAttributeIndex, float flValue );
  117. CEconItemAttribute( const attrib_definition_index_t iAttributeIndex, uint32 unValue );
  118. CEconItemAttribute & operator=( const CEconItemAttribute &val );
  119. // Get the index of this attribute's definition inside the script file
  120. attrib_definition_index_t GetAttribIndex( void ) const { return m_iAttributeDefinitionIndex; }
  121. void SetAttribIndex( attrib_definition_index_t iIndex ) { m_iAttributeDefinitionIndex = iIndex; }
  122. // Get the static data contained in this attribute's definition
  123. const CEconItemAttributeDefinition *GetStaticData( void ) const;
  124. // Get the float value of this attribute.
  125. float GetValue( void ) const;
  126. // Get the value of this attribute as an unsigned integer.
  127. uint32 GetIntValue( void ) const;
  128. float GetInitialValue( void ) const { return m_flInitialValue; }
  129. int GetRefundableCurrency( void ) const { return m_nRefundableCurrency; }
  130. void AddRefundableCurrency( int nAdd ) { m_nRefundableCurrency += nAdd; }
  131. void RemovedRefundableCurrency( int nSubtract ) { m_nRefundableCurrency -= nSubtract; }
  132. // Get & Set the setbonus flag. Allowed to set it here because it doesn't affect attribute caches.
  133. bool GetSetBonus( void ) { return m_bSetBonus; }
  134. void SetSetBonus( bool bBonus ) { m_bSetBonus = bBonus; }
  135. private:
  136. // The only way to set the value of an attribute after its creation is through the attribute list
  137. // that contains it. This way the matching attribute manager is told one of its attributes has changed.
  138. // Set the float value of this attribute.
  139. // Note that the value must be stored as a float!
  140. void SetValue( float flValue );
  141. // Set the value of this attribute as an unsigned integer.
  142. // Note that the value must be stored as an integer!
  143. // See CEconItemAttributeDefinition
  144. void SetIntValue( uint32 unValue );
  145. friend class CAttributeList;
  146. friend class CEconItemSystem;
  147. void Init( void );
  148. //--------------------------------------------------------
  149. private:
  150. // This is the index of the attribute into the attributes read from the data files
  151. CNetworkVar( attrib_definition_index_t, m_iAttributeDefinitionIndex );
  152. // This is the value of the attribute. Used to modify the item's variables.
  153. CNetworkVar( float, m_flValue );
  154. // This is the value that the attribute was first set to by an item definition
  155. CNetworkVar( float, m_flInitialValue );
  156. CNetworkVar( int, m_nRefundableCurrency );
  157. CNetworkVar( bool, m_bSetBonus ); // Attribute has been generated by a set bonus.
  158. public:
  159. // Used for copy constructor only
  160. CEconItemAttribute( void );
  161. };
  162. //-----------------------------------------------------------------------------
  163. // Purpose: An item that knows how to read itself from a datafile, describe itself to the user,
  164. // and serialize itself between Servers, Clients, and Steam.
  165. //
  166. // In the client DLL, we derive it from CDefaultClientRenderable so that
  167. // it can be passed in the pProxyData parameter of material proxies.
  168. //-----------------------------------------------------------------------------
  169. #if defined(CLIENT_DLL)
  170. class CEconItemView : public CDefaultClientRenderable, public IEconItemInterface, public CCustomMaterialOwner
  171. #else
  172. class CEconItemView : public IEconItemInterface
  173. #endif
  174. {
  175. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  176. DECLARE_CLASS_NOBASE( CEconItemView );
  177. public:
  178. DECLARE_EMBEDDED_NETWORKVAR();
  179. DECLARE_DATADESC();
  180. #endif
  181. public:
  182. CEconItemView();
  183. CEconItemView( const CEconItemView &src );
  184. virtual ~CEconItemView();
  185. CEconItemView& operator=( const CEconItemView &src );
  186. bool operator==( const CEconItemView &other ) const;
  187. bool operator!=( const CEconItemView &other ) const { return !operator==( other ); }
  188. virtual const GameItemDefinition_t *GetItemDefinition() const
  189. {
  190. return GetStaticData();
  191. }
  192. public:
  193. // IEconItemInterface implementation.
  194. virtual int32 GetQuality() const;
  195. virtual int32 GetRarity() const;
  196. virtual style_index_t GetStyle() const;
  197. virtual uint8 GetFlags() const;
  198. virtual eEconItemOrigin GetOrigin() const;
  199. virtual uint16 GetQuantity() const;
  200. virtual const char *GetCustomName() const;
  201. virtual const char *GetCustomDesc() const;
  202. virtual int GetItemSetIndex() const;
  203. virtual bool GetInUse() const { return GetSOCData() ? GetSOCData()->GetInUse() : false; }
  204. virtual void IterateAttributes( class IEconItemAttributeIterator *pIterator ) const OVERRIDE;
  205. bool IsValid( void ) const { return m_bInitialized; }
  206. void Invalidate( void );
  207. // Initialize from the specified data
  208. // client will load SO cache as needed
  209. void Init( int iDefIndex, int iQuality, int iLevel, uint32 iAccountID = 0 );
  210. void SetInitialized( bool bInit ) { m_bInitialized = bInit; }
  211. bool Init( CEconItem* pItem );
  212. // Get the static data contained in this item's definition
  213. const GameItemDefinition_t *GetStaticData( void ) const;
  214. void SetNonSOEconItem( CEconItem* pItem ) { m_pNonSOEconItem = pItem; }
  215. void MarkDescriptionDirty( void );
  216. virtual bool IsStyleUnlocked( int iStyle ) const;
  217. private:
  218. void EnsureDescriptionIsBuilt( void ) const;
  219. public:
  220. void SetGrayedOutReason( const char *pszGrayedOutReason );
  221. // Set & Get the index of this item's definition inside the script file
  222. void SetItemIndex( item_definition_index_t iIndex ) { m_iItemDefinitionIndex = iIndex; MarkDescriptionDirty(); }
  223. item_definition_index_t GetItemIndex( void ) const { return m_iItemDefinitionIndex; }
  224. // Set & Get the quality & level of this item.
  225. void SetItemQuality( int iQuality ) { m_iEntityQuality = iQuality; MarkDescriptionDirty(); }
  226. int GetItemQuality( void ) const { return m_iEntityQuality; }
  227. void SetItemLevel( uint32 unLevel ) { m_iEntityLevel = unLevel; MarkDescriptionDirty(); }
  228. uint32 GetItemLevel( void ) const { return m_iEntityLevel; }
  229. int GetItemQuantity() const;
  230. #ifdef CLIENT_DLL
  231. void SetIsStoreItem( bool bIsStoreItem ) { m_bIsStoreItem = bIsStoreItem; MarkDescriptionDirty(); }
  232. void SetIsTradeItem( bool bIsTradeItem ) { m_bIsTradeItem = bIsTradeItem; MarkDescriptionDirty(); }
  233. void SetItemQuantity( int iQuantity ) { m_iEntityQuantity = iQuantity; MarkDescriptionDirty(); }
  234. void SetClientItemFlags( uint8 unFlags );
  235. void SetItemRarityOverride( int iRarity ) { m_iRarityOverride = iRarity; MarkDescriptionDirty(); }
  236. void SetItemQualityOverride( int iQuality ) { m_iQualityOverride = iQuality; MarkDescriptionDirty(); }
  237. void SetItemStyleOverride( style_index_t unNewStyleOverride );
  238. #endif
  239. style_index_t GetItemStyle() const;
  240. // Access the worldwide global index of this item
  241. void SetItemID( itemid_t iIdx ) { m_iItemID = iIdx; m_iItemIDHigh = (m_iItemID >> 32); m_iItemIDLow = (m_iItemID & 0xFFFFFFFF); }
  242. #ifdef CLIENT_DLL
  243. // On the client, we need to rebuild it from the high & low networked pieces
  244. virtual itemid_t GetItemID( void ) const { uint64 iTmp = ((((int64)m_iItemIDHigh)<<32) | m_iItemIDLow); return (itemid_t)iTmp; }
  245. #else
  246. itemid_t GetItemID( void ) const { return m_iItemID; }
  247. #endif
  248. uint32 GetItemIDHigh( void ) const { return m_iItemIDHigh; }
  249. uint32 GetItemIDLow( void ) const { return m_iItemIDLow; }
  250. itemid_t GetFauxItemIDFromDefinitionIndex( void ) const;
  251. uint32 GetAccountID( void ) const { return m_iAccountID; }
  252. // Access the inventory position of this item
  253. void SetInventoryPosition( uint32 iPosition ) { m_iInventoryPosition = iPosition; }
  254. const uint32 GetInventoryPosition( void ) const { return m_iInventoryPosition; }
  255. // Return the model to use for model panels containing this item
  256. const char *GetInventoryModel( void );
  257. // Return the image to use for model panels containing this item
  258. const char *GetInventoryImage( void ) const;
  259. bool HasGeneratedInventoryImage( void ) const;
  260. bool GetInventoryImageData( int *iPosition, int *iSize );
  261. const char *GetInventoryOverlayImage( int idx );
  262. int GetInventoryOverlayImageCount( void );
  263. IMaterial *GetToolStickerMaterial( void );
  264. bool IsStickerTool( void );
  265. // Return the model to use when displaying this model on the player character model, if any
  266. const char *GetPlayerDisplayModel( int iClass = 0 ) const;
  267. // Return the model to use when displaying this model in the world. See the notes on this in econ_item_schema.h
  268. const char *GetWorldDisplayModel();
  269. const char *GetExtraWearableModel();
  270. const char *GetIconDisplayModel();
  271. const char *GetBuyMenuDisplayModel();
  272. const char *GetWorldDroppedModel();
  273. const char *GetPedestalDisplayModel();
  274. const char *GetMagazineModel();
  275. // A piece of geometry that masks the scope lens out of the full-screen zoomed blur effect
  276. const char *GetScopeLensMaskModel();
  277. // Return the viewmodel stattrak module model path
  278. const char *GetStatTrakModelByType( int nStatTrakType );
  279. // Return the viewmodel uid module model path
  280. const char *GetUidModel();
  281. // Return the load-out slot that this item must be placed into
  282. int GetAnimationSlot( void );
  283. // Return an int that indicates whether the item should be dropped from a dead owner.
  284. int GetDropType( void );
  285. // Remove all attributes on this item
  286. void DestroyAllAttributes( void );
  287. // Add an attribute to this item
  288. void AddAttribute( CEconItemAttribute *pAttribute );
  289. void SetOrAddAttributeValueByName( const char *pszAttribDefName, float flValue );
  290. void InitNetworkedDynamicAttributesForDemos( void );
  291. void UpdateNetworkedDynamicAttributesForDemos( attrib_definition_index_t nDef, float flNewValue );
  292. #if defined(CSTRIKE_CLIENT_DLL)
  293. void UpdateGeneratedMaterial( bool bIgnorePicMip = false, CompositeTextureSize_t diffuseTextureSize = COMPOSITE_TEXTURE_SIZE_512 );
  294. #endif //#if defined(CSTRIKE_CLIENT_DLL)
  295. // Return the sticker model path for the given index
  296. const char *GetStickerSlotModelBySlotIndex( int nIndex );
  297. int GetNumSupportedStickerSlots( void );
  298. Vector GetStickerSlotWorldProjectionStartBySlotIndex( int nIndex );
  299. Vector GetStickerSlotWorldProjectionEndBySlotIndex( int nIndex );
  300. const char *GetStickerWorldModelBoneParentNameBySlotIndex( int nIndex );
  301. const char *GetStickerSlotMaterialBySlotIndex( int nIndex );
  302. IMaterial *GetStickerIMaterialBySlotIndex( int nIndex, bool bThirdPerson = false );
  303. void GenerateStickerMaterials( void );
  304. bool ItemHasAnyStickersApplied( void );
  305. bool ItemHasAnyFreeStickerSlots( void );
  306. int GetStickerSlotFirstFreeFromIndex( int nIndex = 0 );
  307. void SetCustomNameOverride( const char *pszCustomName );
  308. // These functions are used by the client, as well as the server (in cs_gamestats.cpp)
  309. virtual void GenerateKillEaterTypeVector( void );
  310. virtual void GetKillEaterTypes( CUtlSortVector<uint32> &types );
  311. virtual int32 GetKillEaterValueByType( uint32 uKillEaterType );
  312. bool m_bKillEaterTypesCached;
  313. CUtlSortVector<uint32> m_vCachedKillEaterTypes;
  314. int m_nKillEaterValuesCacheFrame;
  315. CUtlHashtable<uint32, int32> m_vCachedKillEaterValues;
  316. private:
  317. void Cleanup( void );
  318. #if defined(CSTRIKE_CLIENT_DLL)
  319. // create custom materials based on the custom attributes
  320. void CreateCustomWeaponMaterials( int nWeaponId, bool bIgnorePicMip, CompositeTextureSize_t diffuseTextureSize = COMPOSITE_TEXTURE_SIZE_512 );
  321. void CreateCustomClothingMaterials( const char *pchSkinIdent, int nSlotId, int nTeam, bool bIgnorePicMip, CompositeTextureSize_t diffuseTextureSize = COMPOSITE_TEXTURE_SIZE_512 );
  322. public:
  323. void Update( void );
  324. void SaveInventoryImageAsPNG( int nWidth, int nHeight );
  325. const CUtlBuffer *GetInventoryImageRgba( int nWidth, int nHeight, ImageReadyCallback_t pImageReadyCallback );
  326. bool CanGenerateInventoryImageRgba( void );
  327. void ClearInventoryImageRgba( void );
  328. bool LoadCachedInventoryImage( void );
  329. void SaveInventoryImage( CUtlBuffer &rawImageRgba );
  330. void GenerateCachedInventoryImageName();
  331. static void CleanInventoryImageCacheDir( void );
  332. void FinishLoadCachedInventoryImage( void* pData, int numReadBytes, FSAsyncStatus_t asyncStatus );
  333. enum AsyncFixupState_t
  334. {
  335. AFS_Init, // Initial state, need to load data
  336. AFS_LoadingInProgress, // Async load kicked-off on job thread
  337. AFS_LoadingDone, // Async load done, data ready for fixup on main thread
  338. AFS_FixupDone, // Data fixed up on main thread
  339. } m_asyncFixupState;
  340. int m_nNumAsyncReadBytes;
  341. FSAsyncStatus_t m_asyncStatus;
  342. CUtlBuffer m_inventoryImageRgba;
  343. private:
  344. static bool m_sbHasCleanedInventoryImageCacheDir;
  345. bool m_bInventoryImageRgbaRequested;
  346. bool m_bInventoryImageTriedCache;
  347. ImageReadyCallback_t m_pImageReadyCallback;
  348. int m_nInventoryImageRgbaWidth;
  349. int m_nInventoryImageRgbaHeight;
  350. FSAsyncControl_t m_hAsyncControl;
  351. char m_szCurrentLoadCachedFileName[ MAX_PATH ];
  352. RenderToRTData_t *m_pRenderToRTData;
  353. IVTFTexture *m_pScratchVTF;
  354. CMergedMDL *m_pRenderToRTMDL;
  355. #endif //#if defined(CSTRIKE_CLIENT_DLL)
  356. CUtlVector< stickerMaterialReference_t > m_pStickerMaterials;
  357. // Remove an attribute by name
  358. void RemoveAttribute( const char *pszAttribDefName );
  359. public:
  360. const bool GetCombinedAttributeClassValue( float &flValue, string_t iszAttribClass ) const;
  361. // Returns the attribute matching the specified class, carried by this entity, if it exists.
  362. CEconItemAttribute *GetAttributeByClass( const char *szAttribClass );
  363. const CEconItemAttribute *GetAttributeByClass( const char *szAttribClass ) const;
  364. // Returns the attribute that matches the attribute def index, if it exists
  365. CEconItemAttribute *GetAttributeByDefIndex( int iAttributeDefIndex );
  366. const CEconItemAttribute *GetAttributeByDefIndex( int iAttributeDefIndex ) const;
  367. // Returns the attribute that matches the def name, if it exists
  368. CEconItemAttribute *GetAttributeByName( const char *pszAttribDefName );
  369. const CEconItemAttribute *GetAttributeByName( const char *pszAttribDefName ) const;
  370. // Attribute accessing
  371. int GetNumAttributes( void ) const { return m_AttributeList.GetNumAttributes(); }
  372. CEconItemAttribute *GetAttribute( int iIndex ) { return m_AttributeList.GetAttribute( iIndex ); }
  373. const CEconItemAttribute *GetAttribute( int iIndex ) const { return m_AttributeList.GetAttribute( iIndex ); }
  374. CAttributeList *GetAttributeList( void ) { return m_AttributeList.Get(); }
  375. const CAttributeList *GetAttributeList( void ) const { return m_AttributeList.Get(); }
  376. // Items that have attributes that modify their RGB values
  377. int GetModifiedRGBValue( bool bAltColor=false );
  378. int GetCustomPaintKitIndex( void ) const;
  379. const char* GetCustomPaintKitDbgName( void ) const;
  380. // Returns true if subject is a part of this item's collection set and is not yet collected.
  381. bool CanCollect( CEconItemView &subject );
  382. // Returns the UGC file ID of the custom texture assigned to this item. If non-zero, then it has a custom texture.
  383. uint64 GetCustomUserTextureID();
  384. const CPaintKit *GetCustomPaintKit( void ) const;
  385. CEconItem *GetSOCData( void ) const;
  386. bool IsEquipped( void ) const { return GetSOCData() && GetSOCData()->IsEquipped(); }
  387. bool IsEquippedForClass( equipped_class_t unClass ) const { return GetSOCData() && GetSOCData()->IsEquippedForClass( unClass ); }
  388. void UpdateEquippedState( equipped_class_t unClass, equipped_slot_t unSlot ) { if ( GetSOCData() ) { GetSOCData()->UpdateEquippedState( unClass, unSlot ); } }
  389. equipped_slot_t GetEquippedPositionForClass( equipped_class_t unClass ) const { return GetSOCData() ? GetSOCData()->GetEquippedPositionForClass( unClass ) : INVALID_EQUIPPED_SLOT; }
  390. EItemSlot GetSlot( void ) const { return EItemSlotFromName( GetItemDefinition()->GetRawDefinition()->GetString("item_slot") ); }
  391. // Attached particle systems
  392. int GetQualityParticleType();
  393. int GetSkin() const;
  394. #if defined(CSTRIKE_CLIENT_DLL)
  395. IVisualsDataProcessor *GetVisualsDataProcessor( int nIndex ) { return ( nIndex < m_ppVisualsDataProcessors.Count() ) ? m_ppVisualsDataProcessors[ nIndex ] : NULL; }
  396. IVisualsDataProcessor *GetVisualsDataProcessorByName( const char* szName ) const;
  397. static CEconItemView * FindOrCreateEconItemViewForItemID( uint64 uiItemId );
  398. #else
  399. typedef CUtlMap< itemid_t, uint64, int, CDefLess< itemid_t > > UtlMapLookupByID_t;
  400. static UtlMapLookupByID_t s_mapLookupByID;
  401. #endif
  402. #if defined ( GAME_DLL )
  403. void UpdateNetworkedCustomName();
  404. #endif
  405. protected:
  406. // Index of the item definition in the item script file.
  407. CNetworkVar( item_definition_index_t, m_iItemDefinitionIndex );
  408. // The quality of this item.
  409. CNetworkVar( int, m_iEntityQuality );
  410. // The level of this item.
  411. CNetworkVar( uint32, m_iEntityLevel );
  412. // The global index of this item, worldwide.
  413. itemid_t m_iItemID;
  414. CNetworkVar( uint32, m_iItemIDHigh );
  415. CNetworkVar( uint32, m_iItemIDLow );
  416. // Account ID of the person who has this in their inventory
  417. CNetworkVar( uint32, m_iAccountID );
  418. // Position inside the player's inventory
  419. CNetworkVar( uint32, m_iInventoryPosition );
  420. // This is an alternate source of data, if this item models something that isn't in the SO cache.
  421. CEconItem* m_pNonSOEconItem;
  422. CNetworkVar( bool, m_bInitialized );
  423. #if defined( CLIENT_DLL )
  424. // exist on the client only
  425. bool m_bIsStoreItem;
  426. bool m_bIsTradeItem;
  427. int m_iEntityQuantity;
  428. int m_iRarityOverride;
  429. int m_iQualityOverride;
  430. uint8 m_unClientFlags;
  431. // clients have the ability to force a style on an item view -- this is used for store previews,
  432. // character panels, etc.
  433. style_index_t m_unOverrideStyle;
  434. public:
  435. // Return the single-line name of this item.
  436. const wchar_t *GetItemName( bool bUncustomized = false ) const;
  437. // Return the full structure with all of our description lines.
  438. const class CEconItemDescription *GetDescription() const { EnsureDescriptionIsBuilt(); return m_pDescription; }
  439. private:
  440. mutable class CEconItemDescription *m_pDescription;
  441. mutable char *m_pszGrayedOutReason;
  442. #endif
  443. #if defined(CSTRIKE_CLIENT_DLL)
  444. CUtlVector< IVisualsDataProcessor* > m_ppVisualsDataProcessors;
  445. #endif
  446. protected:
  447. #if defined(CLIENT_DLL)
  448. // IClientRenderable
  449. virtual const Vector& GetRenderOrigin( void ) { return vec3_origin; }
  450. virtual const QAngle& GetRenderAngles( void ) { return vec3_angle; }
  451. virtual bool ShouldDraw( void ) { return false; }
  452. virtual bool IsTransparent( void ) { return false;}
  453. virtual const matrix3x4_t &RenderableToWorldTransform() { static matrix3x4_t mat; SetIdentityMatrix( mat ); return mat; }
  454. virtual void GetRenderBounds( Vector& mins, Vector& maxs ) { return; }
  455. #endif
  456. private:
  457. CNetworkVarEmbedded( CAttributeList, m_AttributeList );
  458. CNetworkVarEmbedded( CAttributeList, m_NetworkedDynamicAttributesForDemos );
  459. // the above attribute lists store all attributes as floats... since we only have one string attribute
  460. // we're networking it separately instead of doing the work to expand attribute lists to support string attrs.
  461. CNetworkString( m_szCustomName, MAX_ITEM_CUSTOM_NAME_DATABASE_SIZE );
  462. char m_szCustomNameOverride[ MAX_ITEM_CUSTOM_NAME_DATABASE_SIZE ];
  463. GCSDK::CAutoPtr< char > m_autoptrInventoryImageGeneratedPath;
  464. };
  465. #endif // ECON_ITEM_CONSTANTS_H