585 {
586 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
587 {
588 return GetFocusedContainer().Select();
589 }
590 else
591 {
593 EntityAI selected_item = ItemManager.GetInstance().GetSelectedItem();
594 SlotsIcon focused_slot = GetFocusedSlotsIcon();
596 if( focused_slot.
IsReserved() || focused_item != selected_item )
597 {
598 if( selected_item )
599 {
600 if( selected_item.GetInventory().CanRemoveEntity() )
601 {
602 if (
m_Player.GetInventory().CanAddAttachmentEx( selected_item, focused_slot.
GetSlotID() ))
603 {
604 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Player, selected_item, focused_slot.
GetSlotID());
605
606 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
607 return true;
608
609 }
610 else if (
m_Player.GetInventory().CanAddAttachment( selected_item ))
611 {
612 player.PredictiveTakeEntityToTargetAttachment(
m_Player, selected_item );
613
614 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
615 return true;
616 }
617 }
618 }
619 else
620 {
621 if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
622 {
623 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
624 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
625 {
626 if( GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
627 {
628 player.PredictiveSwapEntities( item_in_hands, focused_item );
629 return true;
630 }
631 else
632 {
633 InventoryLocation il_hands_dst = new InventoryLocation;
635 {
637
638 if ( player.NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.
GetParent()) ||
GetGame().
GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(),
GetGame().
GetPlayer()) )
640
641 player.GetHumanInventory().ForceSwapEntities( invMode, focused_item, item_in_hands, il_hands_dst );
642 return true;
643 }
644 }
645 }
646 else
647 {
648 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
649 {
650 player.PredictiveTakeEntityToHands( focused_item );
651 return true;
652 }
653 }
654 }
655 }
656 }
657 }
658 return false;
659 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
FindInventoryLocationType
flags for searching locations in inventory
proto native EntityAI GetParent()
returns parent of current inventory location
proto native CGame GetGame()