39 {
40 Man player =
g_Game.GetPlayer();
41 SlotsIcon focused_icon = GetFocusedSlotsIcon();
42 EntityAI focused_item = GetFocusedItem();
43 Container focused_cont = GetFocusedContainer();
44 ItemBase selected_item =
ItemBase.Cast(ItemManager.GetInstance().GetSelectedItem());
45
46 if (selected_item && focused_item != selected_item)
47 {
48 if (selected_item.GetInventory().CanRemoveEntity())
49 {
50 int stack_max;
51
52 if (!focused_icon)
53 {
54 if (focused_cont)
55 {
57 }
58 }
60 {
61 stack_max = InventorySlots.GetStackMaxForSlotId(focused_icon.
GetSlotID());
62 float quantity = selected_item.GetQuantity();
63 if (stack_max == 0 || stack_max >= quantity || !selected_item.
CanBeSplit())
64 {
65 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, focused_icon.
GetSlotID());
66 return true;
67 }
68 else
69 {
71 return true;
72 }
73 }
75 {
76 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
77 {
78 InventoryLocation inv_loc = new InventoryLocation;
79 focused_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
80 stack_max = InventorySlots.GetStackMaxForSlotId(inv_loc.
GetSlot());
81 quantity = focused_item.GetQuantity();
82 if (focused_item.CanBeCombined(
ItemBase.Cast(selected_item)))
83 {
84 focused_item.CombineItemsClient(selected_item, true);
85 return true;
86 }
87 else if (stack_max == 0 && GameInventory.CanSwapEntitiesEx(focused_item, selected_item))
88 {
89 player.PredictiveSwapEntities(selected_item, focused_item);
90 return true;
91 }
93 {
94 if (focused_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
95 {
96 SplitItemUtils.TakeOrSplitToInventory(PlayerBase.Cast(player), focused_item, selected_item);
97 return true;
98 }
99 }
100 }
101 }
102 }
103 }
104 else
105 {
106 if (focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.
IsOutOfReach()))
107 {
109 if (item_in_hands && item_in_hands.GetInventory().CanRemoveEntity())
110 {
111 if (GameInventory.CanSwapEntitiesEx(item_in_hands, focused_item))
112 {
113 player.PredictiveSwapEntities(item_in_hands, focused_item);
114 return true;
115 }
116 }
117 else
118 {
119 if (player.GetHumanInventory().CanAddEntityInHands(focused_item))
120 {
121 player.PredictiveTakeEntityToHands(focused_item);
122 return true;
123 }
124 }
125 }
126 }
127
128 return false;
129 }
class GP5GasMask extends MaskBase ItemBase
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
proto native GameInventory GetInventory()
proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot)
Check if attachment can be added to slot @NOTE: Note that slot index IS NOT slot ID!...
proto native int GetSlot()
returns slot id if current type is Attachment
override bool CanBeSplit()