DayZ 1.24
Loading...
Searching...
No Matches
VicinityContainer Class Reference
Inheritance diagram for VicinityContainer:
[legend]
Collaboration diagram for VicinityContainer:
[legend]

Protected Member Functions

void VicinityContainer (LayoutHolder parent, int sort=-1)
 
bool IsVicinityContainerIconsActive ()
 
VicinitySlotsContainer GetVicinityIconsContainer ()
 
bool IsContainerWithCargoActive ()
 
bool IsItemWithAttachmentsActive ()
 
bool IsItemWithCategoriesActive ()
 
void TraverseShowedItems ()
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
void DraggingOverIcon (Widget w, int x, int y, Widget receiver)
 
void OnDropReceivedFromIcon (Widget w, int x, int y, Widget receiver)
 
void OnLeftPanelDropReceived (Widget w, int x, int y, Widget receiver)
 
void OnDropReceivedFromEmptySpace (Widget w, int x, int y, Widget receiver)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
override void UpdateInterval ()
 
void ToggleContainer (Widget w, EntityAI item)
 
override bool CanOpenCloseContainerEx (EntityAI focusedEntity)
 
void ToggleContainer (notnull Container conta)
 
override void ExpandCollapseContainer ()
 
override bool OnChildRemove (Widget w, Widget child)
 
override bool OnChildAdd (Widget w, Widget child)
 
override void CollapseButtonOnMouseButtonDown (Widget w)
 
void UpdateHeader (EntityAI entity, Container cont, PlayerBase player)
 Updates header dragability to be consistent with current 'icon' behaviour.
 
override bool SplitItem ()
 

Protected Attributes

bool m_IsProcessing = false
 
const float DISTANCE_TO_ENTITIES = 1.0
 
const float DISTANCE_TO_THE_REST = 0.5
 

Private Attributes

ref VicinitySlotsContainer m_VicinityIconsContainer
 
ref map< EntityAI, ref Containerm_ShowedItems = new ref map<EntityAI, ref Container>
 
ref map< int, ref Containerm_ShowedItemsIDs = new ref map<int, ref Container>
 
ref array< EntityAIm_ShowedItemIcons = new array<EntityAI>
 
ref map< CargoBase, ref Containerm_ShowedCargos = new ref map<CargoBase, ref Container>
 
- Private Attributes inherited from CollapsibleContainer
ref CollapsibleHeader m_CollapsibleHeader
 
bool m_Hidden
 

Additional Inherited Members

- Private Member Functions inherited from CollapsibleContainer
void CollapsibleContainer (LayoutHolder parent, int sort=-1)
 
override void SetLayoutName ()
 
EntityAI GetEntity ()
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
override void Refresh ()
 
override void OnShow ()
 
override void OnHide ()
 
override void Insert (LayoutHolder container, int pos=-1, bool immedUpdate=true)
 
override void Remove (LayoutHolder container)
 
bool CanDisplayAnyCategory ()
 
void UpdateCollapseButtons ()
 
void LoadDefaultState ()
 
bool IsHidden ()
 
void CollapseButtonOnMouseButtonDown (Widget w)
 
override void Toggle ()
 
override bool OnChildRemove (Widget w, Widget child)
 
override bool OnChildAdd (Widget w, Widget child)
 
override Header GetHeader ()
 
override void SetHeader (Header header)
 
void SetCollapsibleHeaderArrowState (bool open)
 

Detailed Description

Definition at line 1 of file VicinityContainer.c.

Constructor & Destructor Documentation

◆ VicinityContainer()

void VicinityContainer::VicinityContainer ( LayoutHolder parent,
int sort = -1 )
inlineprotected

Definition at line 13 of file VicinityContainer.c.

14 {
16 m_Body.Insert(m_VicinityIconsContainer);
17 m_VicinityIconsContainer.GetRootWidget().SetColor(166 << 24 | 120 << 16 | 120 << 8 | 120);
18 m_MainWidget = m_RootWidget.FindAnyWidget("body");
19 WidgetEventHandler.GetInstance().RegisterOnChildAdd(m_MainWidget, this, "OnChildAdd");
20 WidgetEventHandler.GetInstance().RegisterOnChildRemove(m_MainWidget, this, "OnChildRemove");
21
22 RecomputeOpenedContainers();
23 m_CollapsibleHeader.SetName("#container_vicinity");
25 }
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
ref CollapsibleHeader m_CollapsibleHeader
ref VicinitySlotsContainer m_VicinityIconsContainer
static WidgetEventHandler GetInstance()

References WidgetEventHandler::GetInstance(), CollapsibleContainer::LoadDefaultState(), CollapsibleContainer::m_CollapsibleHeader, m_RootWidget, and m_VicinityIconsContainer.

Member Function Documentation

◆ CanOpenCloseContainerEx()

override bool VicinityContainer::CanOpenCloseContainerEx ( EntityAI focusedEntity)
inlineprotected

Definition at line 551 of file VicinityContainer.c.

552 {
553 if (focusedEntity)
554 {
556 if (c && c.IsDisplayable())
557 return true;
558 }
559 return false;
560 }
ref map< EntityAI, ref Container > m_ShowedItems

References m_ShowedItems.

◆ CollapseButtonOnMouseButtonDown()

override void VicinityContainer::CollapseButtonOnMouseButtonDown ( Widget w)
inlineprotected

Definition at line 604 of file VicinityContainer.c.

605 {
606 super.CollapseButtonOnMouseButtonDown(w);
607 ItemManager.GetInstance().SetDefaultHeaderOpenState("VICINITY", !m_Hidden);
608 }
static ItemManager GetInstance()

References ItemManager::GetInstance(), and CollapsibleContainer::m_Hidden.

◆ DraggingOverHeader()

override void VicinityContainer::DraggingOverHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 87 of file VicinityContainer.c.

88 {
89 if (w == null)
90 return;
91
92 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
93 if (!ipw)
94 {
95 string name = w.GetName();
96 name.Replace("PanelWidget", "Render");
97 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
98 }
99
100 if (!ipw && ItemPreviewWidget.Cast(w))
101 ipw = ItemPreviewWidget.Cast(w);
102
103 if (!ipw || !ipw.GetItem())
104 return;
105
106 if (ipw.GetItem() && GetGame().GetPlayer().CanDropEntity(ipw.GetItem()) && ipw.GetItem().GetInventory().CanRemoveEntity() && m_ShowedItemIcons.Find(ipw.GetItem()) == -1)
107 {
109 ItemManager.GetInstance().HideDropzones();
110 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
111 }
112 else
113 {
115 ItemManager.GetInstance().ShowSourceDropzone(ipw.GetItem());
116 }
117 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerBase GetPlayer()
static int GREEN_COLOR
static int RED_COLOR
static ColorManager GetInstance()
ref array< EntityAI > m_ShowedItemIcons
proto native CGame GetGame()

References GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), GetPlayer(), ColorManager::GREEN_COLOR, m_ShowedItemIcons, name, and ColorManager::RED_COLOR.

◆ DraggingOverIcon()

void VicinityContainer::DraggingOverIcon ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 119 of file VicinityContainer.c.

120 {
121 string name = receiver.GetName();
122 name.Replace("PanelWidget", "Render");
125
126 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
127 if (!ipw)
128 {
129 name = w.GetName();
130 name.Replace("PanelWidget", "Render");
131 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
132 }
133
134 if (!ipw && ItemPreviewWidget.Cast(w))
135 ipw = ItemPreviewWidget.Cast(w);
136
137 if (!ipw)
138 return;
139
140 if (!ItemBase.Cast(receiver_item) || !ipw.GetItem())
141 return;
142
143 if (ipw.GetItem().GetInventory().CanRemoveEntity() || m_ShowedItemIcons.Find(ipw.GetItem()) > -1)
144 {
145 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(ipw.GetItem())))
146 {
148 ItemManager.GetInstance().HideDropzones();
149 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
150 return;
151 }
153 {
155 ItemManager.GetInstance().HideDropzones();
156 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
157 return;
158 }
159 /*else if( GetGame().GetPlayer().CanDropEntity( ipw.GetItem() ) )
160 {
161 ColorManager.GetInstance().SetColor( w, ColorManager.GREEN_COLOR );
162 ItemManager.GetInstance().HideDropzones();
163 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
164 return;
165 }*/
166 }
167
169 ItemManager.GetInstance().ShowSourceDropzone(ipw.GetItem());
170 }
static int COMBINE_COLOR
static int SWAP_COLOR
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:610

References GameInventory::CanSwapEntitiesEx(), ColorManager::COMBINE_COLOR, ColorManager::GetInstance(), ItemManager::GetInstance(), m_ShowedItemIcons, name, ColorManager::RED_COLOR, and ColorManager::SWAP_COLOR.

◆ ExpandCollapseContainer()

override void VicinityContainer::ExpandCollapseContainer ( )
inlineprotected

Definition at line 568 of file VicinityContainer.c.

569 {
572
573 if (m_ShowedItems && item)
574 {
575 conta = m_ShowedItems.Get(item);
576 if (conta)
578 }
579 }
override EntityAI GetFocusedItem()
void ToggleContainer(Widget w, EntityAI item)

References Container::GetFocusedItem(), m_ShowedItems, and ToggleContainer().

◆ GetVicinityIconsContainer()

VicinitySlotsContainer VicinityContainer::GetVicinityIconsContainer ( )
inlineprotected

Definition at line 32 of file VicinityContainer.c.

33 {
35 }

References m_VicinityIconsContainer.

◆ IsContainerWithCargoActive()

bool VicinityContainer::IsContainerWithCargoActive ( )
inlineprotected

Definition at line 37 of file VicinityContainer.c.

38 {
39 return (ContainerWithCargo.Cast(GetFocusedContainer()) != null);
40 }

◆ IsItemWithAttachmentsActive()

bool VicinityContainer::IsItemWithAttachmentsActive ( )
inlineprotected

Definition at line 42 of file VicinityContainer.c.

43 {
44 return (ContainerWithCargoAndAttachments.Cast(GetFocusedContainer()) != null);
45 }

◆ IsItemWithCategoriesActive()

bool VicinityContainer::IsItemWithCategoriesActive ( )
inlineprotected

Definition at line 47 of file VicinityContainer.c.

48 {
49 return (AttachmentCategoriesContainer.Cast(GetFocusedContainer()) != null);
50 }

◆ IsVicinityContainerIconsActive()

bool VicinityContainer::IsVicinityContainerIconsActive ( )
inlineprotected

Definition at line 27 of file VicinityContainer.c.

28 {
29 return m_VicinityIconsContainer.IsActive();
30 }

References m_VicinityIconsContainer.

◆ OnChildAdd()

override bool VicinityContainer::OnChildAdd ( Widget w,
Widget child )
inlineprotected

Definition at line 594 of file VicinityContainer.c.

595 {
596 if (w == GetMainWidget())
597 {
598 GetMainWidget().Update();
599 m_Parent.OnChildAdd(w, child);
600 }
601 return true;
602 }
Widget m_Parent
Definition SizeToChild.c:86

References m_Parent.

◆ OnChildRemove()

override bool VicinityContainer::OnChildRemove ( Widget w,
Widget child )
inlineprotected

Definition at line 581 of file VicinityContainer.c.

582 {
583 w.Update();
584 float x, y;
585 w.GetScreenSize(x, y);
586 if (w == GetMainWidget())
587 {
588 GetMainWidget().Update();
589 m_Parent.OnChildRemove(w, child);
590 }
591 return true;
592 }
Icon x
Icon y

References m_Parent, x, and y.

◆ OnDropReceivedFromEmptySpace()

void VicinityContainer::OnDropReceivedFromEmptySpace ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 228 of file VicinityContainer.c.

229 {
231 }
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)

References OnDropReceivedFromHeader(), x, and y.

◆ OnDropReceivedFromHeader()

override void VicinityContainer::OnDropReceivedFromHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 233 of file VicinityContainer.c.

234 {
235 if (!w)
236 return;
237
238 ItemManager.GetInstance().HideDropzones();
239 ItemManager.GetInstance().SetIsDragging(false);
240
241 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
242
243 if (!ipw)
244 {
245 string name = w.GetName();
246 name.Replace("PanelWidget", "Render");
247 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
248 }
249
250 if (!ipw)
251 {
252 ipw = ItemPreviewWidget.Cast(w);
253 if (!ipw)
254 return;
255 }
256
257 EntityAI item = ipw.GetItem();
258 if (!ipw.IsInherited(ItemPreviewWidget) || !item)
259 return;
260
261 if (!item.GetInventory().CanRemoveEntity() || m_ShowedItemIcons.Find(item) > -1)
262 return;
263
265 if (player.CanDropEntity(item))
266 {
268 if (itemBase)
269 {
270 if (itemBase.GetTargetQuantityMax() < itemBase.GetQuantity())
271 itemBase.SplitIntoStackMaxClient(null, -1);
272 else
273 player.PhysicalPredictiveDropItem(itemBase);
274 }
275 }
276
277 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
278 if (menu)
279 menu.RefreshQuickbar();
280 }
void InventoryMenu()
const int MENU_INVENTORY
Definition constants.c:170

References GetGame(), ItemManager::GetInstance(), GetPlayer(), InventoryMenu(), m_ShowedItemIcons, MENU_INVENTORY, and name.

Referenced by OnDropReceivedFromEmptySpace(), and OnLeftPanelDropReceived().

◆ OnDropReceivedFromIcon()

void VicinityContainer::OnDropReceivedFromIcon ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 172 of file VicinityContainer.c.

173 {
174 string name = receiver.GetName();
175 name.Replace("PanelWidget", "Render");
178
179 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
180 if (!ipw)
181 {
182 name = w.GetName();
183 name.Replace("PanelWidget", "Render");
184 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
185 }
186
187 if (!ItemBase.Cast(receiver_item) || !ipw.GetItem())
188 return;
189
190 EntityAI item = ipw.GetItem();
191 bool equal_typed = item.GetType() == receiver_item.GetType();
192 if (!receiver_item.IsInherited(ItemBase) || item == null)
193 return;
194
196
197 if (!item.GetInventory().CanRemoveEntity())
198 return;
199
200 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(item)))
203 {
206 receiver_item.GetInventory().GetCurrentInventoryLocation(il1);
207 item.GetInventory().GetCurrentInventoryLocation(il2);
208
209 if (!receiver_item.GetInventory().CanRemoveEntity() || (il1.GetType() == InventoryLocationType.GROUND && il2.GetType() == InventoryLocationType.GROUND))
210 return;
211 player.PredictiveSwapEntities(item, receiver_item);
212 }
213
214 ItemManager.GetInstance().HideDropzones();
215 ItemManager.GetInstance().SetIsDragging(false);
216 PrepareOwnedTooltip(item);
217
218 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
219 if (menu)
220 menu.RefreshQuickbar();
221 }
InventoryLocationType
types of Inventory Location
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5528
InventoryLocation.

References GameInventory::CanSwapEntitiesEx(), CombineItemsClient(), GetGame(), ItemManager::GetInstance(), GetPlayer(), InventoryMenu(), MENU_INVENTORY, and name.

◆ OnLeftPanelDropReceived()

void VicinityContainer::OnLeftPanelDropReceived ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 223 of file VicinityContainer.c.

224 {
226 }

References OnDropReceivedFromHeader(), x, and y.

◆ SplitItem()

override bool VicinityContainer::SplitItem ( )
inlineprotected

Definition at line 623 of file VicinityContainer.c.

624 {
625 if (CanSplit())
626 {
628 if (item)
629 {
630 if (item.HasQuantity() && item.CanBeSplit())
631 item.OnRightClick();
632 }
633 }
634 return false;
635 }

References Container::GetFocusedItem().

◆ ToggleContainer() [1/2]

void VicinityContainer::ToggleContainer ( notnull Container conta)
inlineprotected

Definition at line 563 of file VicinityContainer.c.

564 {
565 conta.Toggle();
566 }

◆ ToggleContainer() [2/2]

void VicinityContainer::ToggleContainer ( Widget w,
EntityAI item )
inlineprotected

Definition at line 538 of file VicinityContainer.c.

539 {
541 Container c;
542 w.GetUserData(slots_icon);
543
544 if (item)
545 c = Container.Cast(m_ShowedItems.Get(item));
546
547 if (c)
549 }

References m_ShowedItems, and ToggleContainer().

Referenced by ExpandCollapseContainer(), and ToggleContainer().

◆ TraverseShowedItems()

void VicinityContainer::TraverseShowedItems ( )
inlineprotected

Definition at line 52 of file VicinityContainer.c.

53 {
55 for (int i = 0; i < m_ShowedItems.Count(); i++)
56 {
58 Container container = m_ShowedItems.GetElement(i);
59 string type = entity.GetType();
60 if (container.IsInherited(ContainerWithCargo))
61 {
62 if (!serialized_types.Contains(type))
63 {
64 ContainerWithCargo item_with_cargo = ContainerWithCargo.Cast(container);
65 serialized_types.Insert(type, item_with_cargo.IsOpened());
66 }
67 }
68 }
69
70 if (serialized_types.Count() > 0)
71 {
73 if (file.Open("inventory_state.save", FileMode.APPEND))
74 {
75 file.Write(serialized_types.Count());
76
77 for (i = 0; i < serialized_types.Count(); i++)
78 {
79 file.Write(serialized_types.GetKey(i));
80 file.Write(serialized_types.GetElement(i));
81 }
82 }
83 file.Close();
84 }
85 }
Serializer API implementation for File IO. See Serializer for more info. usage:
Definition Serializer.c:104
FileMode
Definition EnSystem.c:383

References m_ShowedItems.

◆ UpdateHeader()

void VicinityContainer::UpdateHeader ( EntityAI entity,
Container cont,
PlayerBase player )
inlineprotected

Updates header dragability to be consistent with current 'icon' behaviour.

Definition at line 611 of file VicinityContainer.c.

612 {
613 bool draggable = ItemManager.GetInstance().EvaluateContainerDragabilityDefault(entity);
614
615 if (cont.GetHeader())
616 {
617 if (GetDragWidget() == cont.GetHeader())
619 ItemManager.GetInstance().SetWidgetDraggable(cont.GetHeader().GetMainWidget(), draggable);
620 }
621 }
proto native Widget CancelWidgetDragging()
proto native Widget GetDragWidget()

References CancelWidgetDragging(), GetDragWidget(), and ItemManager::GetInstance().

Referenced by UpdateInterval().

◆ UpdateInterval()

override void VicinityContainer::UpdateInterval ( )
inlineprotected

Allow view access of inventory if in free camera. Write access is elsewhere

Allow view access of inventory if in free camera. Write access is elsewhere

Definition at line 282 of file VicinityContainer.c.

283 {
285
286 if (!player)
287 return;
288
289 super.UpdateInterval();
290
292 vector pos = player.GetPosition();
294
295 VicinityItemManager.GetInstance().Update(player.GetDeltaT());
296 objects = VicinityItemManager.GetInstance().GetVicinityItems();
297
298 //GetItemsShowableInInventory
301 m_ShowedItemIcons.Clear();
302
303 GameInventory game_inventory = player.GetInventory();
304 for (int i = 0; i < objects.Count(); i++)
305 {
306 eai = objects.Get(i);
307 if (eai == null || game_inventory.IsPlaceholderEntity(eai))
308 continue; // noproxy: ignore body placeholder
309
311 if (base_building && !base_building.IsPlayerInside(player, ""))
312 continue;
313
314 if (eai.IsInventoryVisible())
315 {
316 showable_items.Insert(eai);
317
318 if (!eai.IsInherited(DayZInfected) && !eai.IsInherited(PlayerBase) && !eai.IsInherited(AnimalBase) && !eai.DisableVicinityIcon())
319 m_ShowedItemIcons.Insert(eai);
320 }
321 }
322
323
324 //MW HOTFIX - old containers must be removed before new one are added (part of initialize are refreshed whole structure - need proper fix to avoid it)
327
328 for (i = 0; i < showable_items.Count(); i++)
330
331
332 bool need_update_focus = false;
333 for (i = 0; i < m_ShowedItems.Count(); i++)
334 {
335 EntityAI ent = m_ShowedItems.GetKey(i);
336 m_ShowedItems.GetElement(i).UpdateInterval();
337 con = m_ShowedItems.GetElement(i);
338 if (!new_showed_items.Contains(ent))
339 {
340 GetMainWidget().Update();
341 if (con.IsActive())
342 need_update_focus = true;
343 Container.Cast(GetParent()).Remove(con);
344 Remove(con);
345 }
346 else
347 {
348 UpdateHeader(ent, con, player); //squeezed here, the map is iterated over enough already..
349 }
350 }
352
353 bool accessInventory = PlayerBase.DEBUG_INVENTORY_ACCESS;
354 accessInventory |= FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive();
355
356
357 //ref map<EntityAI, ref Container> new_showed_items = new ref map<EntityAI, ref Container>;
358 new_showed_items.Clear();
360 for (i = 0; i < showable_items.Count(); i++)
361 {
363 if (entity)
364 {
365 if (game_inventory && !m_ShowedItems.Contains(entity))
366 {
367 string config = "CfgVehicles " + entity.GetType() + " GUIInventoryAttachmentsProps";
368
369 if (GetGame().ConfigIsExisting(config))
370 {
372 ac.SetEntity(entity);
373 new_showed_items.Insert(entity, ac);
374 showed_items_IDs.Insert(entity.GetID(), ac);
375 }
376 else if (entity.GetSlotsCountCorrect() > 0 && entity.GetInventory().GetCargo())
377 {
378 if (entity.IsInherited(DayZInfected))
379 {
380 if (entity.IsAlive())
381 continue;
383 zmb_cnt.SetEntity(entity);
385 showed_items_IDs.Insert(entity.GetID(), zmb_cnt);
386 Container.Cast(GetParent()).Insert(zmb_cnt);
387 }
388 else
389 {
390 ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments(this, -1);
391 iwca.SetEntity(entity, false);
393 showed_items_IDs.Insert(entity.GetID(), iwca);
394 }
395 }
396 else if (entity.GetInventory().GetCargo())
397 {
398 ContainerWithCargo iwc = new ContainerWithCargo(this, -1);
399 iwc.SetEntity(entity, 0, false);
400 new_showed_items.Insert(entity, iwc);
401 showed_items_IDs.Insert(entity.GetID(), iwc);
402 iwc.UpdateInterval();
403 }
404 else if (entity.GetSlotsCountCorrect() > 0)
405 {
406 if (entity.HasEnergyManager())
407 {
409 iwem.SetEntity(entity, false);
411 showed_items_IDs.Insert(entity.GetID(), iwem);
412 }
413 else
414 {
415 if (entity.IsInherited(PlayerBase))
416 {
418 if (accessInventory == false)
419 {
420 if (entity.IsAlive() && (!PlayerBase.Cast(entity).IsUnconscious() && !PlayerBase.Cast(entity).IsRestrained()))
421 continue;
422 }
423
425 plyr_cnt.SetPlayer(PlayerBase.Cast(entity));
426 Container.Cast(GetParent()).Insert(plyr_cnt);
427 (Container.Cast(m_Parent)).Refresh();
429 showed_items_IDs.Insert(entity.GetID(), plyr_cnt);
430 }
431 else
432 {
433 ContainerWithCargoAndAttachments iwcas = new ContainerWithCargoAndAttachments(this, -1);
434 iwcas.SetEntity(entity, false);
436 showed_items_IDs.Insert(entity.GetID(), iwcas);
437 iwcas.UpdateInterval();
438 }
439 }
440 }
441 }
442 else
443 {
444 //TODO MW: remove old containers on one spot (hotfix)
445 con = m_ShowedItems.Get(entity);
446 if (con)
447 {
448 if (entity.IsInherited(PlayerBase))
449 {
451 if (!accessInventory && entity.IsAlive() && (!PlayerBase.Cast(entity).IsUnconscious() && !PlayerBase.Cast(entity).IsRestrained()))
452 {
453 GetMainWidget().Update();
454 if (con.IsActive())
455 need_update_focus = true;
456 Container.Cast(GetParent()).Remove(con);
457 Remove(con);
458 continue;
459 }
460 }
461
462 if (entity.IsInherited(BaseBuildingBase))
463 {
465 {
466 GetMainWidget().Update();
467 if (con.IsActive())
468 need_update_focus = true;
469 Container.Cast(GetParent()).Remove(con);
470 Remove(con);
471 continue;
472 }
473 }
474
476 showed_items_IDs.Insert(entity.GetID(), m_ShowedItemsIDs.Get(entity.GetID()));
477 }
478 }
479 }
480 }
481
483 auto cargoes = VicinityItemManager.GetInstance().GetVicinityCargos();
484 for (i = 0; i < cargoes.Count(); i++)
485 {
486 CargoBase cgo = cargoes.Get(i);
487 if (cgo)
488 {
489 if (game_inventory && !m_ShowedCargos.Contains(cgo))
490 {
491 ContainerWithCargo pxc = new ContainerWithCargo(this, -1);
492 pxc.SetEntity(cgo.GetCargoOwner(), cgo.GetOwnerCargoIndex(), false);
493 new_showed_cargos.Insert(cgo, pxc);
494 pxc.UpdateInterval();
495 }
496 else
497 {
498 if (m_ShowedCargos.Get(cgo))
500 }
501 }
502 }
503
504 for (int ic = 0; ic < m_ShowedCargos.Count(); ic++)
505 {
507 m_ShowedCargos.GetElement(ic).UpdateInterval();
508 if (!new_showed_cargos.Contains(cgo2))
509 {
510 Container con2 = m_ShowedCargos.GetElement(ic);
511 if (con2.IsActive())
512 need_update_focus = true;
513 GetMainWidget().Update();
514 Container.Cast(GetParent()).Remove(con2);
515 Remove(con2);
516 }
517 }
518
522 //Because WTF (zombie container)
523 Container.Cast(GetParent()).RecomputeOpenedContainers();
525 SetFirstActive();
526 //RecomputeOpenedContainers();
528 m_VicinityIconsContainer.ShowItemsInContainers(m_ShowedItemIcons);
529
531 {
532 Inventory in = Inventory.Cast(GetRoot());
533 if (in)
534 in.UpdateConsoleToolbar();
535 }
536 }
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
override bool IsPlayerInside(PlayerBase player, string selection)
Definition Fence.c:577
represents base for cargo storage for entities
Definition Cargo.c:7
override void Remove(LayoutHolder container)
void UpdateHeader(EntityAI entity, Container cont, PlayerBase player)
Updates header dragability to be consistent with current 'icon' behaviour.
ref map< int, ref Container > m_ShowedItemsIDs
ref map< CargoBase, ref Container > m_ShowedCargos
static VicinityItemManager GetInstance()
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389

References GetGame(), VicinityItemManager::GetInstance(), GetParent(), GetPlayer(), Inventory(), BaseBuildingBase::IsPlayerInside(), m_Parent, m_ShowedCargos, m_ShowedItemIcons, m_ShowedItems, m_ShowedItemsIDs, m_VicinityIconsContainer, CollapsibleContainer::Refresh(), CollapsibleContainer::Remove(), CollapsibleContainer::UpdateCollapseButtons(), and UpdateHeader().

Member Data Documentation

◆ DISTANCE_TO_ENTITIES

const float VicinityContainer::DISTANCE_TO_ENTITIES = 1.0
protected

Definition at line 10 of file VicinityContainer.c.

◆ DISTANCE_TO_THE_REST

const float VicinityContainer::DISTANCE_TO_THE_REST = 0.5
protected

Definition at line 11 of file VicinityContainer.c.

◆ m_IsProcessing

bool VicinityContainer::m_IsProcessing = false
protected

Definition at line 8 of file VicinityContainer.c.

◆ m_ShowedCargos

ref map<CargoBase, ref Container> VicinityContainer::m_ShowedCargos = new ref map<CargoBase, ref Container>
private

Definition at line 7 of file VicinityContainer.c.

Referenced by UpdateInterval().

◆ m_ShowedItemIcons

ref array<EntityAI> VicinityContainer::m_ShowedItemIcons = new array<EntityAI>
private

◆ m_ShowedItems

◆ m_ShowedItemsIDs

ref map<int, ref Container> VicinityContainer::m_ShowedItemsIDs = new ref map<int, ref Container>
private

Definition at line 5 of file VicinityContainer.c.

Referenced by UpdateInterval().

◆ m_VicinityIconsContainer

ref VicinitySlotsContainer VicinityContainer::m_VicinityIconsContainer
private

The documentation for this class was generated from the following file: