public void CancelSelection()
        {
            ItemSlotPanel.CancelSelectionAll();
            CraftPanel.Get(player_id)?.CancelSelection();
            CraftSubPanel.Get(player_id)?.CancelSelection();
            ActionSelectorUI.Get(player_id)?.Hide();
            ActionSelector.Get(player_id)?.Hide();

            if (onCancelSelection != null)
            {
                onCancelSelection.Invoke();
            }
        }
        private void OnClickRight(UISlot uislot)
        {
            //Cancel select
            selected_slot       = -1;
            selected_right_slot = -1;
            ActionSelectorUI.Get(GetPlayerID()).Hide();

            //Show action selector
            ItemSlot  islot = (ItemSlot)uislot;
            CraftData item  = islot.GetCraftable();

            if (item != null && item.GetItem() != null && item.GetItem().actions.Length > 0)
            {
                selected_right_slot = islot.index;
                ActionSelectorUI.Get(GetPlayerID()).Show(islot);
            }
        }
        private void OnClick(UISlot uislot)
        {
            if (uislot != null)
            {
                //Cancel right click and action selector
                int previous_right_select = selected_right_slot;
                ActionSelectorUI.Get(GetPlayerID()).Hide();
                selected_right_slot = -1;

                int      slot    = uislot.index;
                ItemSlot selslot = GetSelectedSlotInAllPanels();

                //Cancel action selector
                if (slot == previous_right_select)
                {
                    CancelSelection();
                    return;
                }

                //Merge two slots
                ItemSlot islot = (ItemSlot)uislot;
                if (islot != null && selslot != null)
                {
                    MergeSlots(selslot, (ItemSlot)uislot);
                    if (onMergeSlot != null)
                    {
                        onMergeSlot.Invoke(selslot, islot);
                    }
                }
                //Select slot
                else if (islot.GetCraftable() != null)
                {
                    CancelSelectionAll();
                    selected_slot = slot;

                    ItemData idata = islot?.GetItem();
                    idata?.RunAutoActions(GetPlayer(), islot);

                    if (onSelectSlot != null)
                    {
                        onSelectSlot.Invoke(islot);
                    }
                }
            }
        }
 public void StopNavigate()
 {
     ActionSelector.Get(player_id)?.Hide();
     ActionSelectorUI.Get(player_id)?.Hide();
     UISlotPanel.UnfocusAll();
 }
        protected override void Update()
        {
            base.Update();

            PlayerCharacter character = GetPlayer();
            int             gold      = (character != null) ? character.Data.gold : 0;

            if (gold_value != null)
            {
                gold_value.text = gold.ToString();
            }

            //Init inventories from here because they are disabled
            foreach (ItemSlotPanel panel in item_slot_panels)
            {
                panel.InitPanel();
            }

            //Fx visibility
            damage_fx_timer += Time.deltaTime;

            if (build_mode_text != null)
            {
                build_mode_text.enabled = IsBuildMode();
            }

            if (tps_cursor != null)
            {
                tps_cursor.enabled = TheCamera.Get().IsLocked();
            }

            if (character != null && !character.IsDead() && character.Attributes.IsDepletingHP())
            {
                DoDamageFXInterval();
            }

            //Cold FX
            if (character != null && !character.IsDead())
            {
                PlayerCharacterHeat characterHeat = PlayerCharacterHeat.Get(character.player_id);
                if (cold_fx != null && characterHeat != null)
                {
                    cold_fx.SetVisible(characterHeat.IsCold());
                }
                if (damage_fx != null && characterHeat != null && characterHeat.IsColdDamage())
                {
                    DoDamageFXInterval();
                }
            }

            //Controls
            PlayerControls controls = PlayerControls.Get(player_id);

            if (controls.IsPressCraft())
            {
                CraftPanel.Get(player_id)?.Toggle();
                ActionSelectorUI.Get(player_id)?.Hide();
                ActionSelector.Get(player_id)?.Hide();
            }

            //Backpack panel
            BagPanel bag_panel = BagPanel.Get(player_id);

            if (character != null && bag_panel != null)
            {
                InventoryItemData item  = character.Inventory.GetBestEquippedBag();
                ItemData          idata = ItemData.Get(item?.item_id);
                if (idata != null)
                {
                    bag_panel.ShowBag(character, item.uid, idata.bag_size);
                }
                else
                {
                    bag_panel.HideBag();
                }
            }
        }