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.

74 lines
2.4 KiB

  1. //====== Copyright �, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: EconItemFactory: Manages rolling for items requested by the game server
  4. //
  5. //=============================================================================
  6. #ifndef ECONITEMFACTORY_H
  7. #define ECONITEMFACTORY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CEconItem;
  12. class CEconGameAccount;
  13. namespace GCSDK
  14. {
  15. class CGCSharedObjectCache;
  16. }
  17. #include "game_item_schema.h"
  18. //-----------------------------------------------------------------------------
  19. // CEconItemFactory
  20. // Factory responsible for rolling random items
  21. //-----------------------------------------------------------------------------
  22. class CEconItemFactory
  23. {
  24. public:
  25. CEconItemFactory( );
  26. enum ECreateItemPolicy_t
  27. {
  28. k_ECreateItemPolicy_Default = 0, // Default creating item policy
  29. k_ECreateItemPolicy_NoSqlItemID = ( 1 << 0 ), // Item will have no ItemID generated
  30. };
  31. // Gets a pointer to the underlying item schema the factory is using
  32. GameItemSchema_t &GetSchema() { return m_schema; }
  33. // Create a random item based on the incoming item selection criteria
  34. CEconItem *CreateRandomItem( const CEconGameAccount *pGameAccount, const CItemSelectionCriteria &criteria );
  35. // Create an item from a specific definition index
  36. CEconItem *CreateSpecificItem( const CEconGameAccount *pGameAccount, item_definition_index_t unDefinitionIndex, ECreateItemPolicy_t eCreateItemPolicy = k_ECreateItemPolicy_Default );
  37. CEconItem *CreateSpecificItem( GCSDK::CGCSharedObjectCache *pUserSOCache, item_definition_index_t unDefinitionIndex )
  38. {
  39. return CreateSpecificItem( pUserSOCache->GetSingleton<CEconGameAccount>(), unDefinitionIndex );
  40. }
  41. itemid_t GetNextID();
  42. bool BYieldingInit();
  43. bool BIsInitialized() { return m_bIsInitialized; }
  44. void ApplyStaticAttributeToItem( CEconItem *pItem, const static_attrib_t& staticAttrib, const CEconGameAccount *pGameAccount, const CCopyableUtlVector< uint32 > *m_vecValues = NULL, float flRangeMin = 0.0f, float flRangeMax = 0.0f ) const;
  45. private:
  46. // Functions to create random items
  47. const CEconItemDefinition *RollItemDefinition( const CItemSelectionCriteria &criteria ) const;
  48. void AddGCGeneratedAttributesToItem( const CEconGameAccount *pGameAccount, CEconItem *pItem ) const;
  49. private:
  50. // The schema this factory uses to create items
  51. GameItemSchema_t m_schema;
  52. // the next item ID to give out
  53. itemid_t m_ulNextObjID;
  54. bool m_bIsInitialized;
  55. };
  56. #endif //ECONITEMFACTORY_H