public override void HandleItemDrag(string name, ItemBase draggedItem, DragAndDropManager.DragRemoveItem dragDelegate, SegmentEntity targetEntity)
    {
        ExtraStorageHoppers hopper      = targetEntity as ExtraStorageHoppers;
        ItemBase            itemForSlot = this.GetItemForSlot(hopper, name);
        bool flag = true;

        if (itemForSlot != null)
        {
            flag = (draggedItem.mnItemID == itemForSlot.mnItemID);
        }
        if (hopper.OT && hopper.IsEmpty() && !hopper.ExemplarSet)
        {
            hopper.SetExemplar(draggedItem);
        }
        if (name == "ItemSlot" + this.SlotCount && flag && hopper.IsNotFull() && hopper.CheckExemplar(draggedItem))
        {
            ItemBase itemBase         = ItemManager.CloneItem(draggedItem);
            int      currentStackSize = ItemManager.GetCurrentStackSize(itemBase);
            if (hopper.RemainingCapacity < currentStackSize)
            {
                ItemManager.SetItemCount(itemBase, hopper.RemainingCapacity);
            }
            ExtraStorageHopperWindowNew.StoreItems(WorldScript.mLocalPlayer, hopper, itemBase);
            InventoryPanelScript.mbDirty = true;
            SurvivalHotBarManager.MarkAsDirty();
            SurvivalHotBarManager.MarkContentDirty();
            ExtraStorageHopperWindowNew.networkRedraw = true;
        }
    }
    public static NetworkInterfaceResponse HandleNetworkCommand(Player player, NetworkInterfaceCommand nic)
    {
        ExtraStorageHoppers hopper = nic.target as ExtraStorageHoppers;
        string command             = nic.command;

        if (command != null)
        {
            string text = command;
            switch (text)
            {
            case "SetAddRemove":
                ExtraStorageHopperWindowNew.SetPermissions(player, hopper, eHopperPermissions.AddAndRemove);
                break;

            case "SetAddOnly":
                ExtraStorageHopperWindowNew.SetPermissions(player, hopper, eHopperPermissions.AddOnly);
                break;

            case "SetRemoveOnly":
                ExtraStorageHopperWindowNew.SetPermissions(player, hopper, eHopperPermissions.RemoveOnly);
                break;

            case "SetLocked":
                ExtraStorageHopperWindowNew.SetPermissions(player, hopper, eHopperPermissions.Locked);
                break;

            case "ToggleHoover":
                ExtraStorageHopperWindowNew.ToggleHoover(player, hopper);
                break;

            case "ToggleShare":
                ExtraStorageHopperWindowNew.ToggleShare(player, hopper);
                break;

            case "TakeItems":
                ExtraStorageHopperWindowNew.TakeItems(player, hopper, nic.itemContext);
                break;

            case "StoreItems":
                ExtraStorageHopperWindowNew.StoreItems(player, hopper, nic.itemContext);
                break;

            case "DebugMode":
                ExtraStorageHopperWindowNew.DebugMode(player, hopper);
                break;

            case "SetExemplar":
                ExtraStorageHopperWindowNew.SetNewExamplar(player, hopper, nic.itemContext);
                break;
            }
        }
        return(new NetworkInterfaceResponse
        {
            entity = hopper,
            inventory = player.mInventory
        });
    }
    public override bool ButtonClicked(string name, SegmentEntity targetEntity)
    {
        ExtraStorageHoppers hopper = targetEntity as ExtraStorageHoppers;

        if (name == "AddRemoveButton")
        {
            UIManager.ForceNGUIUpdate = 0.1f;
            ExtraStorageHopperWindowNew.SetPermissions(WorldScript.mLocalPlayer, hopper, eHopperPermissions.AddAndRemove);
            return(true);
        }
        if (name == "AddOnlyButton")
        {
            UIManager.ForceNGUIUpdate = 0.1f;
            ExtraStorageHopperWindowNew.SetPermissions(WorldScript.mLocalPlayer, hopper, eHopperPermissions.AddOnly);
            return(true);
        }
        if (name == "RemoveOnlyButton")
        {
            UIManager.ForceNGUIUpdate = 0.1f;
            ExtraStorageHopperWindowNew.SetPermissions(WorldScript.mLocalPlayer, hopper, eHopperPermissions.RemoveOnly);
            return(true);
        }
        if (name == "LockedButton")
        {
            UIManager.ForceNGUIUpdate = 0.1f;
            ExtraStorageHopperWindowNew.SetPermissions(WorldScript.mLocalPlayer, hopper, eHopperPermissions.Locked);
            return(true);
        }
        if (name == "ToggleHoover")
        {
            UIManager.ForceNGUIUpdate = 0.1f;
            AudioHUDManager.instance.HUDIn();
            ExtraStorageHopperWindowNew.ToggleHoover(WorldScript.mLocalPlayer, hopper);
            return(true);
        }
        if (name == "ToggleShare")
        {
            UIManager.ForceNGUIUpdate = 0.1f;
            AudioHUDManager.instance.HUDIn();
            ExtraStorageHopperWindowNew.ToggleShare(WorldScript.mLocalPlayer, hopper);
            return(true);
        }
        if (name.Contains("ItemSlot"))
        {
            int num = -1;
            int.TryParse(name.Replace("ItemSlot", string.Empty), out num);
            if (num > -1)
            {
                int num2 = 100;
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                {
                    num2 = 10;
                }
                if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                {
                    num2 = 1;
                }
                ItemBase item = ItemManager.CloneItem(this.GetNthItemSlot(hopper, num));
                if (num2 < ItemManager.GetCurrentStackSize(item))
                {
                    ItemManager.SetItemCount(item, num2);
                    if (hopper.IsFull())
                    {
                        ExtraStorageHopperWindowNew.networkRedraw = true;
                    }
                    else
                    {
                        ExtraStorageHopperWindowNew.dirty = true;
                    }
                }
                else
                {
                    ExtraStorageHopperWindowNew.networkRedraw = true;
                }
                ExtraStorageHopperWindowNew.TakeItems(WorldScript.mLocalPlayer, hopper, item);
                UIManager.ForceNGUIUpdate = 0.1f;
                AudioHUDManager.instance.OrePickup();
                if (WorldScript.meGameMode == eGameMode.eSurvival && SurvivalPlayerScript.meTutorialState == SurvivalPlayerScript.eTutorialState.RemoveCoalFromHopper)
                {
                    SurvivalPlayerScript.TutorialSectionComplete();
                }
                typeof(ExtraStorageHoppers).GetField("mRetakeDebounce", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(hopper, 0.5f);
                return(true);
            }
        }
        return(false);
    }