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.

251 lines
9.7 KiB

  1. //====== Copyright � 1996-2010, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef __ECON_ITEM_SYSTEM_INTERFACE_H
  7. #define __ECON_ITEM_SYSTEM_INTERFACE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "utlmap.h"
  12. #include "econ/econ_item_constants.h"
  13. class KeyValues;
  14. class IEconItemSchema;
  15. class CEconItemDefinition;
  16. struct item_list_entry_t;
  17. //-----------------------------------------------------------------------------
  18. // Particle system attachments exposed for editors.
  19. //-----------------------------------------------------------------------------
  20. struct attachedparticlecontrolpoint_t
  21. {
  22. short nControlPoint;
  23. byte nAttachType;
  24. const char *pszAttachmentName;
  25. Vector vecPosition;
  26. };
  27. enum attachedparticle_toent_t
  28. {
  29. ATTPART_TO_SELF,
  30. ATTPART_TO_PARENT,
  31. };
  32. struct attachedparticlesystem_t
  33. {
  34. const char *pszResourceName;
  35. const char *pszSystemName;
  36. const char *pszAttachmentName;
  37. bool bFollowRootBone;
  38. bool bFlyingCourier;
  39. int iCustomType;
  40. int iCount;
  41. int nSystemID;
  42. KeyValues* pEffectKV;
  43. // Advanced particle controlling
  44. byte nRootAttachType;
  45. attachedparticle_toent_t nAttachToEntity;
  46. CCopyableUtlVector<attachedparticlecontrolpoint_t> vecControlPoints;
  47. };
  48. //-----------------------------------------------------------------------------
  49. // Item Attribute
  50. //-----------------------------------------------------------------------------
  51. class IEconItemAttributeDefinition
  52. {
  53. public:
  54. virtual uint16 GetDefinitionIndex( void ) const = 0;
  55. virtual const char *GetDefinitionName( void ) const = 0;
  56. virtual const char *GetDescriptionString( void ) const = 0;
  57. virtual const char *GetAttributeClass( void ) const = 0;
  58. virtual KeyValues* GetRawDefinition( void ) const = 0;
  59. };
  60. //-----------------------------------------------------------------------------
  61. // Loot List
  62. //-----------------------------------------------------------------------------
  63. class IEconLootListDefinition
  64. {
  65. public:
  66. virtual const char *GetName() const = 0;
  67. virtual const CUtlVector<item_list_entry_t>& GetLootListContents() const = 0;
  68. virtual float GetWeight( int iIdx ) const = 0;
  69. virtual KeyValues* GenerateKeyValues() const = 0;
  70. virtual bool IsServerList() const = 0;
  71. // Additional Drops
  72. virtual int GetAdditionalDropCount( void ) const = 0;
  73. virtual bool GetAdditionalDrop( int iIndex, CUtlString& strLootList, float& flChance ) const = 0;
  74. // Random Attributes
  75. virtual int GetRandomAttributeGroupCount( void ) const = 0;
  76. virtual bool GetRandomAttributeGroup( int iIndex, float& flChance, float& flTotalWeight ) const = 0;
  77. virtual int GetRandomAttributeCount( int iGroup ) const = 0;
  78. virtual bool GetRandomAttribute( int iGroup, int iIndex, float& flWeight, int& iValue, int& iDefIndex ) const = 0;
  79. // Editable Interface
  80. virtual void PurgeItems( void ) = 0;
  81. };
  82. //-----------------------------------------------------------------------------
  83. // Item Set
  84. //-----------------------------------------------------------------------------
  85. class IEconItemSetDefinition
  86. {
  87. public:
  88. virtual const char* GetName( void ) const = 0;
  89. virtual const char* GetLocKey( void ) const = 0;
  90. virtual const char* GetUnlocalizedName( void ) const = 0;
  91. virtual int GetBundle( void ) const = 0;
  92. virtual int GetItemCount( void ) const = 0;
  93. virtual int GetItemDef( int iIndex ) const = 0;
  94. virtual int GetItemPaintKit( int iIndex ) const = 0;
  95. virtual item_definition_index_t GetCraftReward( void ) const = 0;
  96. virtual int GetItemRarity( int iIndex ) const = 0;
  97. virtual int GetHighestItemRarityValue( void ) const = 0;
  98. };
  99. //-----------------------------------------------------------------------------
  100. // Static Item Data
  101. //-----------------------------------------------------------------------------
  102. class IEconItemDefinition
  103. {
  104. public:
  105. virtual item_definition_index_t GetDefinitionIndex( void ) const = 0;
  106. virtual const char* GetPrefabName( void ) const = 0;
  107. virtual const char* GetItemBaseName( void ) const = 0;
  108. virtual const char* GetItemTypeName( void ) const = 0;
  109. virtual const char* GetItemDesc( void ) const = 0;
  110. virtual const char* GetInventoryImage( void ) const = 0;
  111. virtual const char* GetBasePlayerDisplayModel() const = 0;
  112. virtual const char* GetWorldDisplayModel() const = 0;
  113. virtual const char* GetExtraWearableModel( void ) const = 0;
  114. virtual int GetLoadoutSlot( void ) const = 0;
  115. virtual KeyValues* GetRawDefinition( void ) const = 0;
  116. virtual int GetHeroID( void ) const = 0;
  117. virtual uint8 GetRarity( void ) const = 0;
  118. virtual const CUtlVector< int >& GetItemSets( void ) const = 0;
  119. virtual int GetBundleItemCount( void ) const = 0;
  120. virtual int GetBundleItem( int iIndex ) const = 0;
  121. virtual bool IsBaseItem( void ) const = 0;
  122. virtual bool IsPublicItem( void ) const = 0;
  123. virtual bool IsBundle( void ) const = 0;
  124. virtual bool IsPackBundle( void ) const = 0;
  125. virtual bool IsPackItem( void ) const = 0;
  126. virtual void BInitVisualBlockFromKV( KeyValues *pKVItem, IEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL ) = 0;
  127. };
  128. //-----------------------------------------------------------------------------
  129. // Item Schema
  130. //-----------------------------------------------------------------------------
  131. class IEconItemSchema
  132. {
  133. public:
  134. // Schema Parsing
  135. virtual bool BInit( const char *fileName, const char *pathID, CUtlVector<CUtlString> *pVecErrors = NULL ) = 0;
  136. virtual bool BInitLootLists( KeyValues *pKVLootLists, KeyValues *pKVRandomAttributeTemplates, CUtlVector<CUtlString> *pVecErrors, bool bServerLists ) = 0;
  137. virtual KeyValues* GetRawDefinition( void ) const = 0;
  138. virtual int GetItemDefinitionCount() = 0;
  139. virtual IEconItemDefinition* GetItemDefinitionInterface( int iDefIndex ) = 0;
  140. virtual IEconItemDefinition* GetDefaultItemDefinitionInterface() = 0;
  141. virtual int GetLoadoutSlotCount() = 0;
  142. virtual const char* GetLoadoutSlotName( int iSlot ) = 0;
  143. virtual int GetLoadoutSlot( const char* pszSlotName ) = 0;
  144. virtual int GetCharacterSlotType( int iCharacter, int iSlot ) = 0;
  145. virtual int GetCharacterID( const char* pszCharacterName ) = 0;
  146. virtual int GetCharacterCount( void ) = 0;
  147. virtual const char* GetCharacterName( int iCharacter ) = 0;
  148. virtual const char* GetCharacterModel( int iCharacter ) = 0;
  149. // Particle Systems
  150. virtual attachedparticlesystem_t* GetAttributeControlledParticleSystem( int id ) = 0;
  151. virtual attachedparticlesystem_t* GetAttributeControlledParticleSystemByIndex( int id ) = 0;
  152. virtual attachedparticlesystem_t* FindAttributeControlledParticleSystem( const char *pchSystemName, int *outID = NULL ) = 0;
  153. virtual int GetNumAttributeControlledParticleSystems() const = 0;
  154. // Quality
  155. virtual int GetQualityDefinitionCount( void ) = 0;
  156. virtual const char* GetQualityName( uint8 iQuality ) = 0;
  157. virtual int GetQualityIndex( const char* pszQuality ) = 0;
  158. // Rarity
  159. virtual int GetRarityDefinitionCount( void ) const = 0;
  160. virtual const char* GetRarityName( uint8 iRarity ) = 0;
  161. virtual const char* GetRarityLocKey( uint8 iRarity ) = 0;
  162. virtual const char* GetRarityColor( uint8 iRarity ) = 0;
  163. virtual const char* GetRarityLootList( uint8 iRarity ) = 0;
  164. virtual int GetRarityIndex( const char* pszRarity ) = 0;
  165. // Attributes
  166. virtual const IEconItemAttributeDefinition *GetAttributeDefinitionInterface( int iAttribIndex ) const = 0;
  167. // Item Sets
  168. virtual int GetItemSetCount( void ) const = 0;
  169. virtual const IEconItemSetDefinition* GetItemSet( int iIndex ) const = 0;
  170. // Loot Lists
  171. virtual void PurgeLootLists( void ) = 0;
  172. virtual const IEconLootListDefinition* GetLootListInterfaceByName( const char* pListName, int *out_piIndex = NULL ) = 0;
  173. virtual const IEconLootListDefinition* GetLootListInterfaceByIndex( int iIdx ) const = 0;
  174. virtual const int GetLootListIndex( const char* pListName ) = 0;
  175. virtual const int GetLootListInterfaceCount( void ) const = 0;
  176. virtual KeyValues *FindDefinitionPrefabByName( const char *pszPrefabName ) const = 0;
  177. // Schema Init, for Editing
  178. virtual attachedparticlesystem_t GetAttachedParticleSystemInfo( KeyValues* pParticleSystemKV, int32 nItemIndex ) const = 0;
  179. virtual bool BInitAttributeControlledParticleSystems( KeyValues *pKVParticleSystems, CUtlVector<CUtlString> *pVecErrors ) = 0;
  180. virtual bool BInitItems( KeyValues *pKVAttributes, CUtlVector<CUtlString> *pVecErrors ) = 0;
  181. virtual bool BInitItemSets( KeyValues *pKVItemSets, CUtlVector<CUtlString> *pVecErrors ) = 0;
  182. virtual bool DeleteItemDefinition( int iDefIndex ) = 0;
  183. // Iterating over the item definitions.
  184. virtual CEconItemDefinition *GetItemDefinitionByName( const char *pszDefName ) = 0;
  185. virtual const CEconItemDefinition *GetItemDefinitionByName( const char *pszDefName ) const = 0;
  186. #if defined(CLIENT_DLL) || defined(GAME_DLL) || defined(CLIENT_EDITOR_DLL)
  187. virtual void ItemTesting_CreateTestDefinition( int iCloneFromItemDef, int iNewDef, KeyValues *pNewKV ) = 0;
  188. virtual void ItemTesting_DiscardTestDefinition( int iDef ) = 0;
  189. #endif
  190. // sound materials
  191. virtual const char* GetSoundMaterialNameByID( int nSoundMaterialID ) = 0;
  192. virtual int GetSoundMaterialID( const char* pszSoundMaterial ) = 0;
  193. // iterating sound materials
  194. virtual int GetSoundMaterialCount( void ) = 0;
  195. virtual int GetSoundMaterialIDByIndex( int nIndex ) = 0; // returns the Nth sound material ID
  196. };
  197. //-----------------------------------------------------------------------------
  198. // Item System
  199. //-----------------------------------------------------------------------------
  200. class IEconItemSystem
  201. {
  202. public:
  203. virtual IEconItemSchema* GetItemSchemaInterface() = 0;
  204. // Item Reservations
  205. virtual void RequestReservedItemDefinitionList() = 0;
  206. virtual void ReserveItemDefinition( uint32 nDefIndex, const char* pszUserName ) = 0;
  207. virtual void ReleaseItemDefReservation( uint32 nDefIndex, const char* pszUserName ) = 0;
  208. };
  209. #endif // __ECON_ITEM_SYSTEM_INTERFACE_H