138 {
139 SlotsIcon selected_slot = ItemManager.GetInstance().GetSelectedIcon();
140 EntityAI selected_item = ItemManager.GetInstance().GetSelectedItem();
144
145 if( focused_slot.
IsReserved() || focused_item != selected_item && !(selected_slot && selected_slot.
IsOutOfReach() ) )
146 {
147 if( selected_item )
148 {
149 if( selected_item.GetInventory().CanRemoveEntity() )
150 {
151 if(
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, focused_slot.
GetSlotID() ) )
152 {
153 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, focused_slot.
GetSlotID() );
154 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
155 return true;
156
157 }
158 else if(
m_Entity.GetInventory().CanAddAttachment( selected_item ) )
159 {
160 player.PredictiveTakeEntityToTargetAttachment(
m_Entity, selected_item);
161 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
162 return true;
163 }
164 }
165 }
166 else
167 {
169 {
171 InventoryLocation il = new InventoryLocation;
172 focused_item.GetInventory().GetCurrentInventoryLocation( il );
173 bool reachable = AttachmentsOutOfReach.IsAttachmentReachable(
m_Entity,
"", il.
GetSlot() );
174 if( reachable && focused_item.GetInventory().CanRemoveEntity() )
175 {
176 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
177 {
178 if( GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
179 {
180 player.PredictiveSwapEntities( item_in_hands, focused_item );
181 return true;
182 }
183 }
184 else
185 {
186 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
187 {
188 player.PredictiveTakeEntityToHands( focused_item );
189 return true;
190 }
191 }
192 }
193 }
194 }
195 }
196 return false;
197 }
SlotsIcon GetFocusedSlotsIcon()
EntityAI GetFocusedItem()
proto native DayZPlayer GetPlayer()
proto native int GetSlot()
returns slot id if current type is Attachment
proto native CGame GetGame()