DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CachedEquipmentStorageBase.c
См. документацию.
7
8class CachedEquipmentItemAttribute
9{
10 int m_SlotIndex = -1;
11
13
16
18
19 bool HasParent()
20 {
21 return m_Parent != null;
22 }
23
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",
39 );
40 }
41
42 return string.Format("entity:%1(%2), parent:%3 , inventoryDepth:%4",
47 );
48 }
49}
50
52{
54
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 // --------------------------------------------------------------------------------
71 {
72 array<Entity> entities = new array<Entity>();
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 // --------------------------------------------------------------------------------
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 {
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
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}
int InventoryDepth()
Определения CachedEquipmentStorageBase.c:24
string Debug()
Определения CachedEquipmentStorageBase.c:29
int m_InventoryDepth
Определения CachedEquipmentStorageBase.c:12
bool HasParent()
Определения CachedEquipmentStorageBase.c:19
class CachedEquipmentStorageQuery m_SlotIndex
ECachedEquipmentPlacement m_InventoryPlacement
Определения CachedEquipmentStorageBase.c:17
Entity m_Entity
Определения CachedEquipmentStorageBase.c:14
Entity m_Parent
Определения CachedEquipmentStorageBase.c:15
ECachedEquipmentItemCategory
Определения ECachedEquipmentItemCategory.c:2
ECachedEquipmentPlacement
Определения ECachedEquipmentPlacement.c:2
void OnItemCargoOut(notnull Entity entity)
bool IsStored(Entity entity, ECachedEquipmentItemCategory category)
Определения CachedEquipmentStorageBase.c:117
void OnItemAttached(notnull Entity entity, int slotId, notnull Entity parent)
array< Entity > GetEntitiesByCategory(CachedEquipmentStorageQuery query)
List of entities matching the CachedEquipmentStorageQuery query.
Определения CachedEquipmentStorageBase.c:70
ref map< ECachedEquipmentItemCategory, ref array< ref CachedEquipmentItemAttribute > > m_ItemsCacheByCategory
Определения CachedEquipmentStorageBase.c:53
void Insert(ECachedEquipmentItemCategory category, CachedEquipmentItemAttribute attributes)
Определения CachedEquipmentStorageBase.c:133
void OnItemDetached(notnull Entity entity, int slotId, notnull Entity parent)
void OnItemCargoIn(notnull Entity entity)
void Remove(ECachedEquipmentItemCategory category, Entity entity)
Определения CachedEquipmentStorageBase.c:144
array< Entity > GetEntitiesByCategory(ECachedEquipmentItemCategory category, ECachedEquipmentPlacement placement=ECachedEquipmentPlacement.ANY)
List of entities matching the category and inventory placement.
Определения CachedEquipmentStorageBase.c:100
ECachedEquipmentItemCategory m_Category
Определения CachedEquipmentStorageBase.c:4
ECachedEquipmentPlacement m_Placement
Определения CachedEquipmentStorageBase.c:5
Определения Camera.c:2
static string EnumToString(typename e, int enumValue)
Return string name of enum value.
Определения EnConvert.c:614
Определения EnConvert.c:603
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения CachedEquipmentStorage.c:4
proto void Print(void var)
Prints content of variable to console/log.
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.