Пример #1
0
        public override bool ButtonClicked(string name, SegmentEntity targetEntity)
        {
            var quantumIoPort = targetEntity as QuantumIoPortMachine;
            var controller    = quantumIoPort.GetController();

            if (controller == null || !controller.IsOperating())
            {
                return(false);
            }

            if (name.Contains("iconItem"))
            {
                int.TryParse(name.Replace("iconItem", string.Empty), out var itemSlot);
                if (itemSlot > -1 && itemSlot < SlotCount)
                {
                    int amount = ItemUtils.GetItemAmoutToRetrieve();

                    var itemBase = ItemManager.CloneItem(controller.GetItem(itemSlot));
                    if (amount < ItemManager.GetCurrentStackSize(itemBase))
                    {
                        ItemManager.SetItemCount(itemBase, amount);
                    }
                    else
                    {
                        amount = ItemManager.GetCurrentStackSize(itemBase);
                    }

                    if (TakeItem(WorldScript.mLocalPlayer, controller, itemBase))
                    {
                        UIManager.ForceNGUIUpdate = 0.1f;
                        AudioHUDManager.instance.OrePickup();
                        return(true);
                    }
                }
            }

            if (name == FindItemButton)
            {
                ItemSearch = true;
                QuantumIoPortItemSearch.SetupUIRules();
                Redraw(targetEntity);
                return(true);
            }

            if (ItemSearch && name.Contains("itemIcon"))
            {
                QuantumIoPortItemSearch.HandleButtonPress(this, name, out var itemBase);
                int amount = ItemUtils.GetItemAmoutToRetrieve();
                if (amount < ItemManager.GetCurrentStackSize(itemBase))
                {
                    ItemManager.SetItemCount(itemBase, amount);
                }
                else
                {
                    amount = ItemManager.GetCurrentStackSize(itemBase);
                }
                if (TakeItem(WorldScript.mLocalPlayer, controller, itemBase))
                {
                    UIManager.ForceNGUIUpdate = 0.1f;
                    AudioHUDManager.instance.OrePickup();
                }
                return(true);
            }

            if (QuantumIoPortItemSearch.HandleButtonPress(this, name, out var selectedItem))
            {
                ItemSearch = false;
                manager.RedrawWindow();
            }

            return(false);
        }