Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
cachedequipmentstoragebase.c
Go to the documentation of this file.
1
class
CachedEquipmentStorageQuery
2
{
3
int
m_MaximumDepth
= -1;
4
ECachedEquipmentItemCategory
m_Category
=
ECachedEquipmentItemCategory
.NONE;
5
ECachedEquipmentPlacement
m_Placement
=
ECachedEquipmentPlacement
.ANY;
6
}
7
8
class
CachedEquipmentItemAttribute
9
{
10
int
m_SlotIndex
= -1;
11
12
int
m_InventoryDepth
;
13
14
Entity
m_Entity
;
15
Entity
m_Parent
;
16
17
ECachedEquipmentPlacement
m_InventoryPlacement
=
ECachedEquipmentPlacement
.ATTACHMENT;
18
19
bool
HasParent
()
20
{
21
return
m_Parent
!= null;
22
}
23
24
int
InventoryDepth
()
25
{
26
return
m_InventoryDepth
;
27
}
28
29
string
Debug
()
30
{
31
if
(
m_SlotIndex
>= 0)
32
{
33
return
string
.Format(
"entity:%1(%2 - %3), parent:%4, inventoryDepth:%5"
,
34
m_Entity
,
35
EnumTools
.
EnumToString
(
ECachedEquipmentPlacement
,
m_InventoryPlacement
),
36
InventorySlots
.
GetSlotName
(
m_SlotIndex
),
37
m_Parent
,
38
m_InventoryDepth
,
39
);
40
}
41
42
return
string
.
Format
(
"entity:%1(%2), parent:%3 , inventoryDepth:%4"
,
43
m_Entity
,
44
EnumTools
.
EnumToString
(
ECachedEquipmentPlacement
,
m_InventoryPlacement
),
45
m_Parent
,
46
m_InventoryDepth
,
47
);
48
}
49
}
50
51
class
CachedEquipmentStorageBase
52
{
53
protected
ref
map<ECachedEquipmentItemCategory, ref array<ref CachedEquipmentItemAttribute>
>
m_ItemsCacheByCategory
;
54
55
void
CachedEquipmentStorageBase
()
56
{
57
m_ItemsCacheByCategory
=
new
map<ECachedEquipmentItemCategory, ref array<ref CachedEquipmentItemAttribute>
>();
58
}
59
60
void
OnItemAttached
(notnull
Entity
entity,
int
slotId, notnull
Entity
parent);
61
void
OnItemDetached
(notnull
Entity
entity,
int
slotId, notnull
Entity
parent);
62
void
OnItemCargoIn
(notnull
Entity
entity);
63
void
OnItemCargoOut
(notnull
Entity
entity);
64
65
// --------------------------------------------------------------------------------
70
array<Entity>
GetEntitiesByCategory
(
CachedEquipmentStorageQuery
query)
71
{
72
array<Entity>
entities =
new
array<Entity>
();
73
if
(
m_ItemsCacheByCategory
[query.
m_Category
])
74
{
75
foreach
(CachedEquipmentItemAttribute itemAttributes :
m_ItemsCacheByCategory
[query.
m_Category
])
76
{
77
bool
placementMatched =
false
;
78
bool
inventoryDepthMatched =
false
;
79
80
if
(itemAttributes.m_InventoryPlacement == query.
m_Placement
|| query.
m_Placement
==
ECachedEquipmentPlacement
.ANY)
81
placementMatched =
true
;
82
83
if
(itemAttributes.m_InventoryDepth <= query.
m_MaximumDepth
|| query.
m_MaximumDepth
== -1)
84
inventoryDepthMatched =
true
;
85
86
if
(placementMatched && inventoryDepthMatched)
87
entities.Insert(itemAttributes.m_Entity);
88
}
89
}
90
91
return
entities;
92
}
93
94
// --------------------------------------------------------------------------------
100
array<Entity>
GetEntitiesByCategory
(
ECachedEquipmentItemCategory
category,
ECachedEquipmentPlacement
placement =
ECachedEquipmentPlacement
.ANY)
101
{
102
array<Entity>
entities =
new
array<Entity>
();
103
if
(
m_ItemsCacheByCategory
[category])
104
{
105
foreach
(CachedEquipmentItemAttribute itemAttributes :
m_ItemsCacheByCategory
[category])
106
{
107
if
(itemAttributes.m_InventoryPlacement == placement || placement ==
ECachedEquipmentPlacement
.ANY)
108
entities.Insert(itemAttributes.m_Entity);
109
}
110
}
111
112
return
entities;
113
}
114
115
// --------------------------------------------------------------------------------
116
117
protected
bool
IsStored
(
Entity
entity,
ECachedEquipmentItemCategory
category)
118
{
119
if
(!
m_ItemsCacheByCategory
.Contains(category))
120
return
false
;
121
122
foreach
(CachedEquipmentItemAttribute itemAttributes :
m_ItemsCacheByCategory
[category])
123
{
124
if
(itemAttributes.m_Entity == entity)
125
return
true
;
126
}
127
128
return
false
;
129
}
130
131
// --------------------------------------------------------------------------------
132
133
protected
void
Insert
(
ECachedEquipmentItemCategory
category, CachedEquipmentItemAttribute attributes)
134
{
135
array<ref CachedEquipmentItemAttribute>
attributesArray =
new
array<ref CachedEquipmentItemAttribute>
();
136
if
(!
m_ItemsCacheByCategory
.Contains(category))
137
m_ItemsCacheByCategory
.Set(category, attributesArray);
138
139
m_ItemsCacheByCategory
[category].Insert(attributes);
140
}
141
142
// --------------------------------------------------------------------------------
143
144
protected
void
Remove
(
ECachedEquipmentItemCategory
category,
Entity
entity)
145
{
146
if
(!
m_ItemsCacheByCategory
.Contains(category))
147
return
;
148
149
array<CachedEquipmentItemAttribute>
toRemove =
new
array<CachedEquipmentItemAttribute>
();
150
foreach
(CachedEquipmentItemAttribute attributeToRemove :
m_ItemsCacheByCategory
[category])
151
{
152
if
(attributeToRemove.m_Entity == entity)
153
toRemove.Insert(attributeToRemove);
154
}
155
156
foreach
(CachedEquipmentItemAttribute attribute : toRemove)
157
m_ItemsCacheByCategory
[category].RemoveItem(attribute);
158
}
159
160
// --------------------------------------------------------------------------------
161
162
#ifdef DIAG_DEVELOPER
163
void
PrintCachedEntitiesByCategory(
ECachedEquipmentItemCategory
category)
164
{
165
if
(
m_ItemsCacheByCategory
[category])
166
{
167
foreach
(CachedEquipmentItemAttribute itemAttributes :
m_ItemsCacheByCategory
[category])
168
{
169
Print
(itemAttributes.Debug());
170
}
171
}
172
}
173
174
// --------------------------------------------------------------------------------
175
176
void
DumpCache()
177
{
178
Print
(
"--------------------------"
);
179
Print
(
"Equipped Items Cache Stats"
);
180
181
array<ECachedEquipmentItemCategory> categories =
m_ItemsCacheByCategory
.GetKeyArray();
182
foreach
(
ECachedEquipmentItemCategory
category : categories)
183
{
184
Print
(
string
.Format(
"[%1]"
, EnumTools.EnumToString(
ECachedEquipmentItemCategory
, category)));
185
PrintCachedEntitiesByCategory(category);
186
}
187
Print
(
"--------------------------"
);
188
}
189
#endif
190
}
InventoryDepth
int InventoryDepth()
Definition
cachedequipmentstoragebase.c:24
Debug
string Debug()
Definition
cachedequipmentstoragebase.c:29
m_InventoryDepth
int m_InventoryDepth
Definition
cachedequipmentstoragebase.c:12
HasParent
bool HasParent()
Definition
cachedequipmentstoragebase.c:19
m_SlotIndex
class CachedEquipmentStorageQuery m_SlotIndex
m_InventoryPlacement
ECachedEquipmentPlacement m_InventoryPlacement
Definition
cachedequipmentstoragebase.c:17
m_Entity
Entity m_Entity
Definition
cachedequipmentstoragebase.c:14
m_Parent
Entity m_Parent
Definition
cachedequipmentstoragebase.c:15
CachedEquipmentStorageBase::IsStored
bool IsStored(Entity entity, ECachedEquipmentItemCategory category)
Definition
cachedequipmentstoragebase.c:117
CachedEquipmentStorageBase::m_ItemsCacheByCategory
ref map< ECachedEquipmentItemCategory, ref array< ref CachedEquipmentItemAttribute > > m_ItemsCacheByCategory
Definition
cachedequipmentstoragebase.c:53
CachedEquipmentStorageBase::OnItemCargoIn
void OnItemCargoIn(notnull Entity entity)
CachedEquipmentStorageBase::Insert
void Insert(ECachedEquipmentItemCategory category, CachedEquipmentItemAttribute attributes)
Definition
cachedequipmentstoragebase.c:133
CachedEquipmentStorageBase::OnItemAttached
void OnItemAttached(notnull Entity entity, int slotId, notnull Entity parent)
CachedEquipmentStorageBase::OnItemCargoOut
void OnItemCargoOut(notnull Entity entity)
CachedEquipmentStorageBase::GetEntitiesByCategory
array< Entity > GetEntitiesByCategory(ECachedEquipmentItemCategory category, ECachedEquipmentPlacement placement=ECachedEquipmentPlacement.ANY)
List of entities matching the category and inventory placement.
Definition
cachedequipmentstoragebase.c:100
CachedEquipmentStorageBase::GetEntitiesByCategory
array< Entity > GetEntitiesByCategory(CachedEquipmentStorageQuery query)
List of entities matching the CachedEquipmentStorageQuery query.
Definition
cachedequipmentstoragebase.c:70
CachedEquipmentStorageBase::OnItemDetached
void OnItemDetached(notnull Entity entity, int slotId, notnull Entity parent)
CachedEquipmentStorageBase::CachedEquipmentStorageBase
void CachedEquipmentStorageBase()
Definition
cachedequipmentstoragebase.c:55
CachedEquipmentStorageBase::Remove
void Remove(ECachedEquipmentItemCategory category, Entity entity)
Definition
cachedequipmentstoragebase.c:144
CachedEquipmentStorageQuery
Definition
cachedequipmentstoragebase.c:2
CachedEquipmentStorageQuery::m_Category
ECachedEquipmentItemCategory m_Category
Definition
cachedequipmentstoragebase.c:4
CachedEquipmentStorageQuery::m_MaximumDepth
int m_MaximumDepth
Definition
cachedequipmentstoragebase.c:3
CachedEquipmentStorageQuery::m_Placement
ECachedEquipmentPlacement m_Placement
Definition
cachedequipmentstoragebase.c:5
Entity
Definition
camera.c:2
EnumTools
Definition
enconvert.c:603
EnumTools::EnumToString
static string EnumToString(typename e, int enumValue)
Return string name of enum value.
Definition
enconvert.c:614
InventorySlots
provides access to slot configuration
Definition
inventoryslots.c:6
InventorySlots::GetSlotName
static proto native owned string GetSlotName(int id)
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
map
Definition
cachedequipmentstorage.c:4
ECachedEquipmentItemCategory
ECachedEquipmentItemCategory
Definition
ecachedequipmentitemcategory.c:2
ECachedEquipmentPlacement
ECachedEquipmentPlacement
Definition
ecachedequipmentplacement.c:2
Print
proto void Print(void var)
Prints content of variable to console/log.
string::Format
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
Games
Dayz
scripts
3_game
entities
cachedequipmentstoragebase.c
Generated by
1.17.0