168 {
170 {
173 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
174 SlotsIcon focused_icon = GetFocusedSlotsIcon();
175
176 if( selected_item )
177 {
179 int stack_max;
180 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
181 {
182 if( !prev_item &&
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
183 {
184 stack_max = InventorySlots.GetStackMaxForSlotId( selected_slot );
185 float quantity = selected_item.GetQuantity();
186 if( stack_max == 0 || stack_max >= quantity || !selected_item.
CanBeSplit() )
187 {
188 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, selected_slot );
189 return true;
190 }
191 else
192 {
193 selected_item.SplitIntoStackMaxClient(
m_Entity, selected_slot );
194 return true;
195 }
196 }
197 else if( selected_slot != -1 )
198 {
199 if( prev_item )
200 {
201 InventoryLocation inv_loc = new InventoryLocation;
202 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
203 stack_max = InventorySlots.GetStackMaxForSlotId( inv_loc.
GetSlot() );
204 quantity = prev_item.GetQuantity();
206 {
207 prev_item.CombineItemsClient( selected_item, true );
208 return true;
209 }
210 else if( stack_max == 0 && GameInventory.CanSwapEntitiesEx( prev_item, selected_item ) )
211 {
212 player.PredictiveSwapEntities( selected_item, prev_item );
213 return true;
214 }
216 {
217 if( prev_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
218 {
219 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( player ), prev_item, selected_item );
220 return true;
221 }
222 }
223 }
224 }
225 }
226 }
227 }
228 return false;
229 }
class GP5GasMask extends MaskBase ItemBase
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
override bool CanCombine()
proto native DayZPlayer GetPlayer()
proto native int GetSlot()
returns slot id if current type is Attachment
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
override bool CanBeSplit()
proto native CGame GetGame()