//When the character interact with this selectable, check all the actions and see if any should be triggered.
        public void Use(PlayerCharacter character, Vector3 pos)
        {
            if (enabled)
            {
                PlayerUI ui   = PlayerUI.Get(character.player_id);
                ItemSlot slot = ui != null?ui.GetSelectedSlot() : null;

                MAction maction = slot != null && slot.GetItem() != null?slot.GetItem().FindMergeAction(this) : null;

                AAction aaction = FindAutoAction(character);
                if (maction != null && maction.CanDoAction(character, slot, this))
                {
                    maction.DoAction(character, slot, this);
                    PlayerUI.Get(character.player_id)?.CancelSelection();
                }
                else if (aaction != null && aaction.CanDoAction(character, this))
                {
                    aaction.DoAction(character, this);
                }
                else if (actions.Length > 0)
                {
                    ActionSelector.Get(character.player_id)?.Show(character, this, pos);
                }

                if (onUse != null)
                {
                    onUse.Invoke(character);
                }
            }
        }
        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();
            }
        }
 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();
                }
            }
        }