670 {
671 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
672 {
673 return GetFocusedContainer().Select();
674 }
675 else
676 {
677 SlotsIcon selected_slot = ItemManager.GetInstance().GetSelectedIcon();
679 EntityAI selected_item = ItemManager.GetInstance().GetSelectedItem();
681 {
682 if( selected_item )
683 {
684 if( selected_item != focused_item)
685 {
686 if( selected_item.GetInventory().CanRemoveEntity() )
687 {
689 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
690 return true;
691 }
692 }
693 }
694 else
695 {
696 if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
697 {
699 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
700 {
701 if( GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
702 {
703 g_Game.GetPlayer().PredictiveSwapEntities( item_in_hands, focused_item );
704 return true;
705 }
706 else
707 {
708 InventoryLocation il_hands_dst = new InventoryLocation;
710 {
712
713 if (
g_Game.GetPlayer().NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.
GetParent()) ||
g_Game.GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(),
g_Game.GetPlayer()) )
715
716 g_Game.GetPlayer().GetHumanInventory().ForceSwapEntities(
InventoryMode.JUNCTURE, focused_item, item_in_hands, il_hands_dst );
717 return true;
718 }
719 }
720 }
721 else
722 {
723 if(
g_Game.GetPlayer().GetHumanInventory().CanAddEntityInHands( focused_item ) )
724 {
725 g_Game.GetPlayer().PredictiveTakeEntityToHands( focused_item );
726 return true;
727 }
728 }
729 }
730 }
731 }
732 }
733 return false;
734 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
FindInventoryLocationType
flags for searching locations in inventory
override EntityAI GetFocusedItem()
proto native EntityAI GetParent()
returns parent of current inventory location