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.

117 lines
4.1 KiB

  1. //========= Copyright (c), Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CSTRIKE15_ITEM_SCHEMA_H
  8. #define CSTRIKE15_ITEM_SCHEMA_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "econ_item_schema.h"
  13. #include "cstrike15_item_constants.h"
  14. class CCStrike15ItemDefinition : public CEconItemDefinition
  15. {
  16. public:
  17. // Constructor
  18. CCStrike15ItemDefinition();
  19. // CCStrike15ItemDefinition interface.
  20. virtual bool BInitFromKV( KeyValues *pKVItem, CEconItemSchema &schemaa, CUtlVector<CUtlString> *pVecErrors = NULL );
  21. #ifndef GC_DLL
  22. virtual bool BInitFromTestItemKVs( int iNewDefIndex, KeyValues *pKVItem, CEconItemSchema &schemaa );
  23. #endif
  24. virtual void CopyPolymorphic( const CEconItemDefinition *pSourceDef );
  25. #ifndef GC_DLL
  26. virtual void GeneratePrecacheModelStrings( bool bDynamicLoad, CUtlVector<const char *> *out_pVecModelStrings );
  27. #endif // !GC_DLL
  28. int GetAnimSlot( void ) const { return m_iAnimationSlot; }
  29. // Class & Slot handling
  30. int GetDefaultLoadoutSlot( void ) const { return m_iDefaultLoadoutSlot; }
  31. const CBitVec<LOADOUT_COUNT> *GetClassUsability( void ) const { return &m_vbClassUsability; }
  32. void FilloutSlotUsage( CBitVec<LOADOUT_COUNT> *pBV ) const;
  33. bool CanBeUsedByTeam( int iTeam ) const { return m_vbClassUsability.IsBitSet( iTeam ); }
  34. int GetUsedByTeam( void ) const;
  35. bool CanBeUsedByAllTeams( void ) const;
  36. bool IsSupplyCrate( void ) const { return m_bIsSupplyCrate; }
  37. // Items that share a slot (m4, cz/p250) have special rules
  38. bool SharesSlot( void ) const { return m_bItemSharesEquipSlot; }
  39. bool CanBePlacedInSlot( int nSlot ) const;
  40. const char *GetPlayerDisplayModel( int iTeam ) const { Assert( iTeam >= 0 && iTeam < LOADOUT_COUNT ); return m_pszPlayerDisplayModel[iTeam]; }
  41. int GetLoadoutSlot( int iLoadoutClass ) const;
  42. #ifndef GC_DLL
  43. bool IsAWearable( int iSlot ) const;
  44. bool IsContentStreamable() const;
  45. #endif // !GC_DLL
  46. private:
  47. // The load-out slot that this item can be placed into.
  48. int m_iDefaultLoadoutSlot;
  49. int m_iAnimationSlot;
  50. // The .mdl file used for this item when it's being carried by a player.
  51. const char *m_pszPlayerDisplayModel[LOADOUT_COUNT];
  52. // Specifies which class can use this item.
  53. CBitVec<LOADOUT_COUNT> m_vbClassUsability;
  54. int m_iLoadoutSlots[LOADOUT_COUNT]; // Slot that each class places the item into.
  55. bool m_bIsSupplyCrate : 1;
  56. bool m_bItemSharesEquipSlot : 1;
  57. };
  58. class CCStrike15ItemSchema : public CEconItemSchema
  59. {
  60. public:
  61. CCStrike15ItemSchema();
  62. CCStrike15ItemDefinition *GetTFItemDefinition( int iItemIndex )
  63. {
  64. return (CCStrike15ItemDefinition *)GetItemDefinition( iItemIndex );
  65. }
  66. const CUtlVector<const char *>& GetClassUsabilityStrings() const { return m_vecClassUsabilityStrings; }
  67. const CUtlVector<const char *>& GetLoadoutStrings() const { return m_vecLoadoutStrings; }
  68. const CUtlVector<const char *>& GetLoadoutStringsSubPositions() const { return m_vecLoadoutStringsSubPositions; }
  69. const CUtlVector<const char *>& GetLoadoutStringsForDisplay() const { return m_vecLoadoutStringsForDisplay; }
  70. const CUtlVector<const char *>& GetWeaponTypeSubstrings() const { return m_vecWeaponTypeSubstrings; }
  71. static const char k_rchCommunitySupportPassItemDefName[];
  72. public:
  73. // CEconItemSchema interface.
  74. virtual CEconItemDefinition *CreateEconItemDefinition() { return new CCStrike15ItemDefinition; }
  75. virtual bool BInitSchema( KeyValues *pKVRawDefinition, CUtlVector<CUtlString> *pVecErrors = NULL );
  76. private:
  77. void InitializeStringTable( const char **ppStringTable, unsigned int unStringCount, CUtlVector<const char *> *out_pvecStringTable );
  78. CUtlVector<const char *> m_vecClassUsabilityStrings;
  79. CUtlVector<const char *> m_vecLoadoutStrings;
  80. CUtlVector<const char *> m_vecLoadoutStringsSubPositions;
  81. CUtlVector<const char *> m_vecLoadoutStringsForDisplay;
  82. CUtlVector<const char *> m_vecWeaponTypeSubstrings;
  83. };
  84. extern const char *g_szLoadoutStrings[ LOADOUT_POSITION_COUNT ];
  85. extern const char *g_szLoadoutStringsForDisplay[ LOADOUT_POSITION_COUNT ];
  86. #endif // CSTRIKE15_ITEM_SCHEMA_H