blob: 5673f28b19be5e4d0eefadcf8c7a45500ad798cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: EconItemFactory: Manages rolling for items requested by the game server
//
//=============================================================================
#ifndef ECONITEMFACTORY_H
#define ECONITEMFACTORY_H
#ifdef _WIN32
#pragma once
#endif
class CEconItem;
class CEconGameAccount;
namespace GCSDK
{
class CGCSharedObjectCache;
}
#include "game_item_schema.h"
//-----------------------------------------------------------------------------
// CEconItemFactory
// Factory responsible for rolling random items
//-----------------------------------------------------------------------------
class CEconItemFactory
{
public:
CEconItemFactory( );
// Gets a pointer to the underlying item schema the factory is using
GameItemSchema_t &GetSchema() { return m_schema; }
// Create a random item based on the incoming item selection criteria
CEconItem *CreateRandomItem( const CEconGameAccount *pGameAccount, const CItemSelectionCriteria &criteria );
// Create an item from a specific definition index
CEconItem *CreateSpecificItem( const CEconGameAccount *pGameAccount, item_definition_index_t unDefinitionIndex );
CEconItem *CreateSpecificItem( GCSDK::CGCSharedObjectCache *pUserSOCache, item_definition_index_t unDefinitionIndex )
{
return CreateSpecificItem( pUserSOCache->GetSingleton<CEconGameAccount>(), unDefinitionIndex );
}
uint64 GetNextID() { Assert( m_bIsInitialized ); return m_ulNextObjID++; }
bool BYieldingInit();
bool BIsInitialized() { return m_bIsInitialized; }
#ifdef DBGFLAG_VALIDATE
virtual void Validate( CValidator &validator, const char *pchName )
{
VALIDATE_SCOPE();
ValidateObj( m_schema );
}
#endif // DBGFLAG_VALIDATE
void ApplyStaticAttributeToItem( CEconItem *pItem, const static_attrib_t& staticAttrib, const CEconGameAccount *pGameAccount ) const;
const CEconItemDefinition *RollItemDefinition( const CItemSelectionCriteria &criteria ) const;
private:
bool BAddGCGeneratedAttributesToItem( const CEconGameAccount *pGameAccount, CEconItem *pItem ) const;
private:
// The schema this factory uses to create items
GameItemSchema_t m_schema;
// the next item ID to give out
itemid_t m_ulNextObjID;
bool m_bIsInitialized;
};
#endif //ECONITEMFACTORY_H
|