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

Protected Member Functions

void ZombieContainer (LayoutHolder parent, int sort=-1)
 
void ~ZombieContainer ()
 
void SetEntity (EntityAI zombie_entity)
 
override void UpdateRadialIcon ()
 
override bool IsItemWithQuantityActive ()
 
bool IsContainerWithCargoActive ()
 
bool IsItemWithAttachmentsActive ()
 
bool IsZombieEquipmentActive ()
 
bool IsItemWithContainerActive ()
 
bool IsEmptyItemActive ()
 
override void ExpandCollapseContainer ()
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
void OnDropReceivedFromGhostArea (Widget w, int x, int y, Widget receiver)
 
void SetHeaderName ()
 
void ItemAttached (EntityAI item, string slot_name)
 
void ItemDetached (EntityAI item, string slot_name)
 
override bool CanOpenCloseContainerEx (EntityAI focusedEntity)
 
void ToggleContainer (Widget w)
 
void MouseClick (Widget w, int x, int y, int button)
 
SlotsIcon GetSlotsIcon (int row, int column)
 
void InitGhostSlots ()
 
void AddSlotsContainer (int row_count)
 
Widget GetWidgetSlot (int slot_number)
 
void DoubleClick (Widget w, int x, int y, int button)
 
override void CollapseButtonOnMouseButtonDown (Widget w)
 
override bool SplitItem ()
 
override bool EquipItem ()
 
override bool TransferItem ()
 
override bool Select ()
 
override bool TransferItemToVicinity ()
 

Protected Attributes

ref AttachmentsGroupContainer m_Container
 
ref ContainerWithCargo m_CargoGrid
 
ref map< int, SlotsIconm_InventorySlots
 
ref map< EntityAI, ref Containerm_ShowedItems = new ref map<EntityAI, ref Container>
 
EntityAI m_ZombieEntity
 

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)
 
- Private Attributes inherited from CollapsibleContainer
ref CollapsibleHeader m_CollapsibleHeader
 
bool m_Hidden
 

Detailed Description

Definition at line 1 of file ZombieContainer.c.

Constructor & Destructor Documentation

◆ ZombieContainer()

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

Definition at line 9 of file ZombieContainer.c.

10 {
13
14 m_Container.SetHeader(GetHeader());
17 m_Body.Insert(m_Container);
18
19 m_MainWidget = m_RootWidget.FindAnyWidget("body");
20
21 WidgetEventHandler.GetInstance().RegisterOnChildAdd(m_MainWidget, this, "OnChildAdd");
22 WidgetEventHandler.GetInstance().RegisterOnChildRemove(m_MainWidget, this, "OnChildRemove");
23
24
25 RecomputeOpenedContainers();
26 }
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
override Header GetHeader()
override void SetHeader(Header header)
static WidgetEventHandler GetInstance()
ref AttachmentsGroupContainer m_Container
ref map< int, SlotsIcon > m_InventorySlots

References CollapsibleContainer::GetHeader(), WidgetEventHandler::GetInstance(), m_Container, m_InventorySlots, m_RootWidget, CollapsibleContainer::SetHeader(), and SetHeaderName().

◆ ~ZombieContainer()

void ZombieContainer::~ZombieContainer ( )
inlineprotected

Definition at line 28 of file ZombieContainer.c.

29 {
31 {
32 m_ZombieEntity.GetOnItemAttached().Remove(ItemAttached);
33 m_ZombieEntity.GetOnItemDetached().Remove(ItemDetached);
34 }
35 }
EntityAI m_ZombieEntity
void ItemAttached(EntityAI item, string slot_name)
void ItemDetached(EntityAI item, string slot_name)

References ItemAttached(), ItemDetached(), and m_ZombieEntity.

Member Function Documentation

◆ AddSlotsContainer()

void ZombieContainer::AddSlotsContainer ( int row_count)
inlineprotected

Definition at line 488 of file ZombieContainer.c.

References m_Container, and m_ZombieEntity.

Referenced by InitGhostSlots().

◆ CanOpenCloseContainerEx()

override bool ZombieContainer::CanOpenCloseContainerEx ( EntityAI focusedEntity)
inlineprotected

Definition at line 295 of file ZombieContainer.c.

296 {
298 if (focusedEntity)
300 else
301 {
302 SlotsIcon icon = GetFocusedSlotsIcon();
303 if (icon)
304 c = ClosableContainer.Cast(icon.GetContainer());
305 }
306
307 if (c && c.IsDisplayable())
308 return true;
309
310 return false;
311 }
ref map< EntityAI, ref Container > m_ShowedItems

References m_ShowedItems.

◆ CollapseButtonOnMouseButtonDown()

override void ZombieContainer::CollapseButtonOnMouseButtonDown ( Widget w)
inlineprotected

Definition at line 560 of file ZombieContainer.c.

561 {
562 super.CollapseButtonOnMouseButtonDown(w);
563 }

◆ DoubleClick()

void ZombieContainer::DoubleClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 503 of file ZombieContainer.c.

504 {
505 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
506 {
507 if (w == null)
508 return;
509 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
510 if (!iw)
511 {
512 string name = w.GetName();
513 name.Replace("PanelWidget", "Render");
514 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
515 }
516
517 if (!iw)
518 iw = ItemPreviewWidget.Cast(w);
519
520 ItemBase item = ItemBase.Cast(iw.GetItem());
521 if (!item)
522 return;
523
525
526 if (player.GetInventory().HasInventoryReservation(item, null) || player.IsItemsToDelete())
527 return;
528
529 if (!item.GetInventory().CanRemoveEntity())
530 return;
531
532 if (player.GetInventory().HasEntityInInventory(item) && GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands(item))
533 player.PredictiveTakeEntityToHands(item);
534 else
535 {
537 if (player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ANY, il))
538 {
539 if (item.GetTargetQuantityMax(il.GetSlot()) < item.GetQuantity())
540 item.SplitIntoStackMaxToInventoryLocationClient(il);
541 else
542 player.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
543 }
544 else if (GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands(item))
545 {
546 if (item.GetTargetQuantityMax() < item.GetQuantity())
547 item.SplitIntoStackMaxHandsClient(player);
548 else
549 player.PredictiveTakeEntityToHands(item);
550 }
551 }
552
553 HideOwnedTooltip();
554 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
555 if (menu)
556 menu.RefreshQuickbar();
557 }
558 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
FindInventoryLocationType
flags for searching locations in inventory
void InventoryMenu()
PlayerBase GetPlayer()
InventoryLocation.
proto native CGame GetGame()
const int MENU_INVENTORY
Definition constants.c:170
MouseState
Definition EnSystem.c:311

References g_Game, GetGame(), GetPlayer(), InventoryMenu(), MENU_INVENTORY, and name.

◆ DraggingOverHeader()

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

Definition at line 128 of file ZombieContainer.c.

129 {
130 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
131 string name = receiver.GetName();
132 name.Replace("PanelWidget", "Render");
135 if (receiver_iw)
136 receiver_item = receiver_iw.GetItem();
137
138 if (!ipw)
139 {
140 name = w.GetName();
141 name.Replace("PanelWidget", "Render");
142 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
143 }
144 if (!ipw)
145 ipw = ItemPreviewWidget.Cast(w);
146
147 if (!ipw.IsInherited(ItemPreviewWidget))
148 return;
149
150 EntityAI item = ipw.GetItem();
152
153 if (!item.GetInventory().CanRemoveEntity())
154 return;
155 }

References GetGame(), GetPlayer(), and name.

◆ EquipItem()

override bool ZombieContainer::EquipItem ( )
inlineprotected

Definition at line 575 of file ZombieContainer.c.

576 {
577 if (CanEquip())
578 {
579 if (GetFocusedContainer().IsInherited(ContainerWithCargo) || GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments))
580 return GetFocusedContainer().EquipItem();
581 else
582 {
584 if (item)
585 {
586 GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.ATTACHMENT, item);
587 return true;
588 }
589 }
590 }
591 return false;
592 }
override EntityAI GetFocusedItem()

References Container::GetFocusedItem(), and GetGame().

◆ ExpandCollapseContainer()

override void ZombieContainer::ExpandCollapseContainer ( )
inlineprotected

Definition at line 93 of file ZombieContainer.c.

94 {
96 {
97 ItemPreviewWidget item_preview = GetFocusedSlotsIcon().GetRender();
98 ToggleContainer(item_preview.GetParent());
99 }
100 }
bool IsZombieEquipmentActive()
void ToggleContainer(Widget w)

References IsZombieEquipmentActive(), and ToggleContainer().

◆ GetSlotsIcon()

SlotsIcon ZombieContainer::GetSlotsIcon ( int row,
int column )
inlineprotected

Definition at line 377 of file ZombieContainer.c.

378 {
380 }
SlotsIcon GetSlotIcon(int index)

References SlotsContainer::GetSlotIcon(), and m_Container.

Referenced by InitGhostSlots().

◆ GetWidgetSlot()

Widget ZombieContainer::GetWidgetSlot ( int slot_number)
inlineprotected

Definition at line 495 of file ZombieContainer.c.

496 {
499
500 return m_Container.Get(row).GetMainWidget().FindAnyWidget("Render" + column);
501 }
const int ITEMS_IN_ROW
Definition Attachments.c:1

References ITEMS_IN_ROW, and m_Container.

◆ InitGhostSlots()

void ZombieContainer::InitGhostSlots ( )
inlineprotected

Definition at line 382 of file ZombieContainer.c.

383 {
384 int row, column;
386 bool has_cargo = m_ZombieEntity.GetInventory().GetCargo() != null;
387
388 string config_path_ghosts_slots = "CfgVehicles ZombieBase InventoryEquipment playerSlots";
391
392 for (int i = 0; i < player_ghosts_slots.Count(); i++)
393 {
394 string slot_name = player_ghosts_slots.Get(i);
395 string path = "CfgSlots" + " " + slot_name;
396
397 if (GetGame().ConfigIsExisting(path))
398 {
399 string icon_name; //icon_name must be in format "set:<setname> image:<imagename>"
400 GetGame().ConfigGetText(path + " ghostIcon", icon_name);
402
403 //START - GetWidgetSlot
404 row = i / ITEMS_IN_ROW;
405 if (row >= m_Container.Count())
406 {
407 if (has_cargo)
408 {
409 if (row < ((player_ghosts_slots.Count() + 1) / ITEMS_IN_ROW))
411 else
413
414 }
415 else
416 {
417 if (row < (player_ghosts_slots.Count() / ITEMS_IN_ROW))
419 else
421 }
422
423 }
424
426
427 icon.GetMainWidget().Show(true);
428 icon.Clear();
429
430 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(icon.GetPanelWidget(), this, "DoubleClick");
431
432 //END - GetWidgetSlot
433 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), this, "OnDropReceivedFromGhostArea");
434 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), this, "OnDropReceivedFromGhostArea");
435 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), this, "DraggingOver");
436 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), this, "DraggingOver");
437 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), this, "DraggingOver");
438 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(icon.GetPanelWidget(), this, "MouseClick");
439
441 //END - LoadIconIntoWidgetSlot
442
443 GetGame().ConfigGetText(path + " name", slot_name);
445 icon.SetSlotID(slot_id);
446 icon.SetSlotDisplayName(InventorySlots.GetSlotDisplayName(slot_id));
448
450 ItemBase item = ItemBase.Cast(m_ZombieEntity.GetInventory().FindAttachment(slot));
451
452 if (item)
454 }
455 }
456
457 if (m_ZombieEntity.GetInventory().GetCargo())
458 {
461 if (row >= m_Container.Count())
462 {
463 if (row < (player_ghosts_slots.Count() + 1 / ITEMS_IN_ROW))
465 else
467 }
468
470 icon.GetMainWidget().Show(true);
471 icon.Clear();
472 icon.GetGhostSlot().LoadImageFile(0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY, m_ZombieEntity.ConfigGetString("GUIInventoryCargoIcon")));
473 icon.SetSlotDisplayName(m_ZombieEntity.ConfigGetString("GUIInventoryCargoName"));
474 icon.GetRadialIconPanel().Show(true);
475 icon.GetRadialIcon().Show(true);
476
477 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetGhostSlot(), this, "ToggleContainer");
478 m_CargoGrid = new ContainerWithCargo(this, false);
479 m_CargoGrid.SetEntity(m_ZombieEntity);
480 m_CargoGrid.GetHeader().GetMainWidget().ClearFlags(WidgetFlags.DRAGGABLE);
482 icon.SetContainer(m_CargoGrid);
483 }
484
485 RecomputeOpenedContainers();
486 }
provides access to slot configuration
static proto native owned string GetSlotDisplayName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static const int IMAGESETGROUP_INVENTORY
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
ref ContainerWithCargo m_CargoGrid
void AddSlotsContainer(int row_count)
SlotsIcon GetSlotsIcon(int row, int column)
WidgetFlags
Definition EnWidgets.c:58

References AddSlotsContainer(), GetGame(), WidgetEventHandler::GetInstance(), InventorySlots::GetSlotDisplayName(), InventorySlots::GetSlotIdFromString(), GetSlotsIcon(), StaticGUIUtils::IMAGESETGROUP_INVENTORY, ItemAttached(), ITEMS_IN_ROW, m_CargoGrid, m_Container, m_InventorySlots, m_ShowedItems, m_ZombieEntity, path, and StaticGUIUtils::VerifyIconImageString().

Referenced by SetEntity().

◆ IsContainerWithCargoActive()

bool ZombieContainer::IsContainerWithCargoActive ( )
inlineprotected

Definition at line 67 of file ZombieContainer.c.

68 {
69 return GetFocusedContainer().IsInherited(ContainerWithCargo);
70 }

◆ IsEmptyItemActive()

bool ZombieContainer::IsEmptyItemActive ( )
inlineprotected

Definition at line 88 of file ZombieContainer.c.

89 {
90 return !GetFocusedItem();
91 }

References Container::GetFocusedItem().

◆ IsItemWithAttachmentsActive()

bool ZombieContainer::IsItemWithAttachmentsActive ( )
inlineprotected

Definition at line 72 of file ZombieContainer.c.

73 {
74 return GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments);
75 }

◆ IsItemWithContainerActive()

bool ZombieContainer::IsItemWithContainerActive ( )
inlineprotected

Definition at line 82 of file ZombieContainer.c.

83 {
85 return ent && (ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0);
86 }

References Container::GetFocusedItem().

◆ IsItemWithQuantityActive()

override bool ZombieContainer::IsItemWithQuantityActive ( )
inlineprotected

Definition at line 61 of file ZombieContainer.c.

62 {
64 return ent && QuantityConversions.HasItemQuantity(ent) && ent.CanBeSplit();
65 }
static int HasItemQuantity(notnull EntityAI item)

References Container::GetFocusedItem(), and QuantityConversions::HasItemQuantity().

◆ IsZombieEquipmentActive()

bool ZombieContainer::IsZombieEquipmentActive ( )
inlineprotected

Definition at line 77 of file ZombieContainer.c.

78 {
79 return GetFocusedContainer() == m_Container;
80 }

References m_Container.

Referenced by ExpandCollapseContainer().

◆ ItemAttached()

void ZombieContainer::ItemAttached ( EntityAI item,
string slot_name )
inlineprotected

Definition at line 219 of file ZombieContainer.c.

220 {
222 SlotsIcon icon = m_InventorySlots.Get(slot);
223 if (icon)
224 {
225 icon.Init(item);
226
227 if (m_ShowedItems.Contains(item) == false)
228 {
229 string name;
230
231 if (item.GetSlotsCountCorrect() > 0)
232 {
233 ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments(this, false);
234 iwca.SetEntity(item);
235 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetPanelWidget(), this, "ToggleContainer");
236
237 icon.GetRadialIconPanel().Show(true);
238 m_ShowedItems.Insert(item, iwca);
239
240 Refresh();
241 }
242 else if (item.GetInventory().GetCargo())
243 {
244 ContainerWithCargo iwc = new ContainerWithCargo(this, false);
245 iwc.SetEntity(item);
246 iwc.UpdateInterval();
247 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetPanelWidget(), this, "ToggleContainer");
248 m_ShowedItems.Insert(item, iwc);
249 icon.GetRadialIconPanel().Show(true);
250
251 Refresh();
252 }
253 }
254
256 string config = "CfgVehicles " + item.GetType() + " GUIInventoryAttachmentsProps";
257 if (conta && conta.IsInherited(ClosableContainer))
258 {
259 bool show_radial_icon = (item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0) && !GetGame().ConfigIsExisting(config);
260 Widget rip = icon.GetRadialIconPanel();
261 Widget icon_open = icon.GetRadialIcon();
262 Widget icon_closed = icon.GetRadialIconClosed();
263 rip.Show(show_radial_icon);
264 icon_open.Show(conta.IsOpened());
265 icon_closed.Show(!conta.IsOpened());
266 }
267 RecomputeOpenedContainers();
268 }
269 }

References GetGame(), WidgetEventHandler::GetInstance(), InventorySlots::GetSlotIdFromString(), m_InventorySlots, m_ShowedItems, name, and CollapsibleContainer::Refresh().

Referenced by InitGhostSlots(), SetEntity(), and ~ZombieContainer().

◆ ItemDetached()

void ZombieContainer::ItemDetached ( EntityAI item,
string slot_name )
inlineprotected

Definition at line 271 of file ZombieContainer.c.

272 {
274 SlotsIcon icon = m_InventorySlots.Get(slot);
275
276 if (icon)
277 {
279 if (con)
280 {
281 (Container.Cast(con.m_Parent)).Remove(con);
282 RecomputeOpenedContainers();
283 GetMainWidget().Update();
284 Refresh();
285 m_ShowedItems.Remove(item);
286 }
287
288 icon.Clear();
289 Inventory in = Inventory.Cast(GetRoot());
290 if (in)
291 in.UpdateConsoleToolbar();
292 }
293 }
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
override void Remove(LayoutHolder container)

References InventorySlots::GetSlotIdFromString(), Inventory(), m_InventorySlots, m_ShowedItems, CollapsibleContainer::Refresh(), and CollapsibleContainer::Remove().

Referenced by SetEntity(), and ~ZombieContainer().

◆ MouseClick()

void ZombieContainer::MouseClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 335 of file ZombieContainer.c.

336 {
339 w.GetUserData(icon);
340 if (icon)
341 selectedItem = ItemBase.Cast(icon.GetEntity());
342
343 if (selectedItem)
344 {
345 switch (button)
346 {
347 case MouseState.RIGHT:
348#ifdef DIAG_DEVELOPER
349 if (GetDayZGame().IsLeftCtrlDown())
350 ShowActionMenu(selectedItem);
351#endif
352 break;
353
354 case MouseState.MIDDLE:
355 InspectItem(selectedItem);
356 break;
357
358 case MouseState.LEFT:
359 if (g_Game.IsLeftCtrlDown())
360 {
362 if (controlledPlayer.CanDropEntity(selectedItem))
363 {
364 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
365 selectedItem.SplitIntoStackMaxClient(null, -1);
366 else
367 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
368
369 ItemManager.GetInstance().SetWidgetDraggable(w, false);
370 }
371 }
372 break;
373 }
374 }
375 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
static ItemManager GetInstance()

References g_Game, GetDayZGame(), GetGame(), ItemManager::GetInstance(), and GetPlayer().

◆ OnDropReceivedFromGhostArea()

void ZombieContainer::OnDropReceivedFromGhostArea ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 157 of file ZombieContainer.c.

158 {
159 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
160 string name = receiver.GetName();
161 name.Replace("PanelWidget", "Render");
164 if (receiver_iw)
165 receiver_item = receiver_iw.GetItem();
166
167 if (!ipw)
168 {
169 name = w.GetName();
170 name.Replace("PanelWidget", "Render");
171 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
172 }
173 if (!ipw)
174 ipw = ItemPreviewWidget.Cast(w);
175
176 if (!ipw.IsInherited(ItemPreviewWidget))
177 return;
178
179 EntityAI item = ipw.GetItem();
181
182 if (!item.GetInventory().CanRemoveEntity())
183 return;
184
185 if (receiver_item)
186 {
187 if (receiver_item.GetInventory().CanAddAttachment(item))
188 {
189 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
190 return;
191 }
192 else if (receiver_item.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && !receiver_item.GetInventory().HasEntityInCargo(item))
193 {
194 player.PredictiveTakeEntityToTargetInventory(receiver_item, FindInventoryLocationType.ANY, item);
195 return;
196 }
197 }
198
199 if (item)
200 {
201 if (m_ZombieEntity.GetInventory().CanAddAttachment(item))
202 player.PredictiveTakeEntityToTargetAttachment(m_ZombieEntity, item);
203 else if (m_ZombieEntity.GetInventory().CanAddEntityToInventory(item))
204 player.PredictiveTakeEntityToTargetInventory(m_ZombieEntity, FindInventoryLocationType.ANY, item);
205 }
206
207 if (item)
208 {
209 if (m_ZombieEntity.GetInventory().CanAddEntityInto(item, FindInventoryLocationType.CARGO))
210 player.PredictiveTakeEntityToTargetInventory(m_ZombieEntity, FindInventoryLocationType.CARGO, item);
211 }
212 }

References GetGame(), GetPlayer(), m_ZombieEntity, and name.

◆ OnDropReceivedFromHeader()

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

Definition at line 102 of file ZombieContainer.c.

103 {
104 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
105 if (!ipw)
106 {
107 string name = w.GetName();
108 name.Replace("PanelWidget", "Render");
109 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
110 }
111 if (!ipw)
112 ipw = ItemPreviewWidget.Cast(w);
113
114 if (!ipw.IsInherited(ItemPreviewWidget))
115 return;
116
117 EntityAI item = ipw.GetItem();
118
119 if (!item.GetInventory().CanRemoveEntity())
120 return;
121
122 if (m_ZombieEntity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()))
123 GetGame().GetPlayer().PredictiveTakeEntityToTargetCargo(m_ZombieEntity, item);
124 else if (m_ZombieEntity.GetInventory().CanAddEntityToInventory(item))
125 GetGame().GetPlayer().PredictiveTakeEntityToTargetInventory(m_ZombieEntity, FindInventoryLocationType.CARGO, item);
126 }

References GetGame(), m_ZombieEntity, and name.

◆ Select()

override bool ZombieContainer::Select ( )
inlineprotected

Definition at line 631 of file ZombieContainer.c.

632 {
633 if (GetFocusedContainer().IsInherited(ContainerWithCargo) || GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments))
634 return GetFocusedContainer().Select();
635 else
636 {
637 SlotsIcon selected_slot = ItemManager.GetInstance().GetSelectedIcon();
639 EntityAI selected_item = ItemManager.GetInstance().GetSelectedItem();
640 if (!(selected_slot && selected_slot.IsOutOfReach()))
641 {
642 if (selected_item)
643 {
645 {
646 if (selected_item.GetInventory().CanRemoveEntity())
647 {
648 GetGame().GetPlayer().PredictiveTakeEntityToTargetInventory(m_ZombieEntity, FindInventoryLocationType.ANY, selected_item);
649 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
650 return true;
651 }
652 }
653 }
654 else
655 {
656 if (focused_item && focused_item.GetInventory().CanRemoveEntity())
657 {
658 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
659 if (item_in_hands && item_in_hands.GetInventory().CanRemoveEntity())
660 {
662 {
663 GetGame().GetPlayer().PredictiveSwapEntities(item_in_hands, focused_item);
664 return true;
665 }
666 else
667 {
669 if (GetGame().GetPlayer().GetHumanInventory().FindFreeLocationFor(item_in_hands, FindInventoryLocationType.ANY, il_hands_dst))
670 {
672
673 if (GetGame().GetPlayer().NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.GetParent()) || GetGame().GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(), GetGame().GetPlayer()))
674 invMode = InventoryMode.JUNCTURE;
675
676 GetGame().GetPlayer().GetHumanInventory().ForceSwapEntities(InventoryMode.JUNCTURE, focused_item, item_in_hands, il_hands_dst);
677 return true;
678 }
679 }
680 }
681 else
682 {
683 if (GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands(focused_item))
684 {
685 GetGame().GetPlayer().PredictiveTakeEntityToHands(focused_item);
686 return true;
687 }
688 }
689 }
690 }
691 }
692 }
693 return false;
694 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
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(), Container::GetFocusedItem(), GetGame(), ItemManager::GetInstance(), GetPlayer(), and m_ZombieEntity.

◆ SetEntity()

void ZombieContainer::SetEntity ( EntityAI zombie_entity)
inlineprotected

Definition at line 37 of file ZombieContainer.c.

38 {
40 m_ZombieEntity.GetOnItemAttached().Insert(ItemAttached);
41 m_ZombieEntity.GetOnItemDetached().Insert(ItemDetached);
43 m_Parent.Refresh();
44 }
Widget m_Parent
Definition SizeToChild.c:86

References InitGhostSlots(), ItemAttached(), ItemDetached(), m_Parent, and m_ZombieEntity.

◆ SetHeaderName()

void ZombieContainer::SetHeaderName ( )
inlineprotected

Definition at line 214 of file ZombieContainer.c.

215 {
216 m_CollapsibleHeader.SetName("#container_inventory");
217 }
ref CollapsibleHeader m_CollapsibleHeader

References CollapsibleContainer::m_CollapsibleHeader.

Referenced by ZombieContainer().

◆ SplitItem()

override bool ZombieContainer::SplitItem ( )
inlineprotected

Definition at line 565 of file ZombieContainer.c.

566 {
567 if (CanSplit())
568 {
569 if (GetFocusedContainer().IsInherited(ContainerWithCargo) || GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments))
570 return GetFocusedContainer().SplitItem();
571 }
572 return false;
573 }

◆ ToggleContainer()

void ZombieContainer::ToggleContainer ( Widget w)
inlineprotected

Definition at line 314 of file ZombieContainer.c.

315 {
319 w.GetUserData(icon);
320 if (icon)
321 item = icon.GetEntity();
322
323 if (item)
325 else
326 c = ClosableContainer.Cast(icon.GetContainer());
327
328
329 if (c)
330 c.Toggle();
331
332 RecomputeOpenedContainers();
333 }

References m_ShowedItems.

Referenced by ExpandCollapseContainer().

◆ TransferItem()

override bool ZombieContainer::TransferItem ( )
inlineprotected

Definition at line 594 of file ZombieContainer.c.

595 {
598 if (CanTakeToInventory())
599 {
600
601 if (left_area)
602 {
603 if (GetFocusedContainer().IsInherited(ContainerWithCargo) || GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments))
604 return GetFocusedContainer().TransferItem();
605 else
606 {
608 if (item)
609 {
610 GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.CARGO, item);
611 return true;
612 }
613 }
614 }
615 else
616 {
617 if (!GetFocusedContainer().IsInherited(ContainerWithCargo) && !GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments))
618 {
620 if (item)
621 {
622 GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.CARGO, item);
623 return true;
624 }
625 }
626 }
627 }
628 return false;
629 }
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389

References Container::GetFocusedItem(), GetGame(), and GetParent().

◆ TransferItemToVicinity()

override bool ZombieContainer::TransferItemToVicinity ( )
inlineprotected

Definition at line 696 of file ZombieContainer.c.

697 {
698 if (CanDrop())
699 {
700 if (GetFocusedContainer().IsInherited(ContainerWithCargo) || GetFocusedContainer().IsInherited(ContainerWithCargoAndAttachments))
701 return GetFocusedContainer().TransferItemToVicinity();
702 else
703 {
704 Man player = GetGame().GetPlayer();
706 if (item && player.CanDropEntity(item))
707 {
708 if (item.GetTargetQuantityMax() < item.GetQuantity())
709 item.SplitIntoStackMaxClient(null, -1);
710 else
711 player.PhysicalPredictiveDropItem(item);
712 return true;
713 }
714 }
715 }
716 return false;
717 }

References Container::GetFocusedItem(), and GetGame().

◆ UpdateRadialIcon()

override void ZombieContainer::UpdateRadialIcon ( )
inlineprotected

Definition at line 46 of file ZombieContainer.c.

47 {
48 if (m_SlotIcon)
49 {
52 Widget rip = m_SlotIcon.GetRadialIconPanel();
53 Widget icon_open = m_SlotIcon.GetRadialIcon();
54 Widget icon_closed = m_SlotIcon.GetRadialIconClosed();
55 rip.Show(!m_ZombieEntity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) && m_ZombieEntity.CanDisplayCargo());
58 }
59 }

References CollapsibleContainer::IsHidden(), and m_ZombieEntity.

Member Data Documentation

◆ m_CargoGrid

ref ContainerWithCargo ZombieContainer::m_CargoGrid
protected

Definition at line 4 of file ZombieContainer.c.

Referenced by InitGhostSlots().

◆ m_Container

ref AttachmentsGroupContainer ZombieContainer::m_Container
protected

◆ m_InventorySlots

ref map<int, SlotsIcon> ZombieContainer::m_InventorySlots
protected

Definition at line 5 of file ZombieContainer.c.

Referenced by InitGhostSlots(), ItemAttached(), ItemDetached(), and ZombieContainer().

◆ m_ShowedItems

ref map<EntityAI, ref Container> ZombieContainer::m_ShowedItems = new ref map<EntityAI, ref Container>
protected

◆ m_ZombieEntity


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