Пример #1
0
        public GuiInventoryBase Show(Inventory playerInventory, int containerId, ContainerType type)
        {
            var dialog = Containers.GetOrAdd(
                containerId, b =>
            {
                GuiInventoryBase inv;
                switch (type)
                {
                //	case ContainerType.DoubleChest:
                //		inv = new GuiChestDialog(new InventoryBase(90));
//
                //		break;
                case ContainerType.Chest:
                    inv = new GuiChestDialog(new InventoryBase(90)
                    {
                        InventoryId = containerId
                    }, playerInventory);

                    break;

                case ContainerType.Furnace:
                    inv = new GuiFurnaceDialog(playerInventory, new InventoryBase(3)
                    {
                        InventoryId = containerId
                    });
                    break;

                default:
                    throw new NotImplementedException();
                }

                inv.Inventory.InventoryId = containerId;

                inv.OnContainerClose += (sender, args) =>
                {
                    Containers.TryRemove(b, out _);

                    if (ActiveWindow == sender)
                    {
                        ActiveWindow = null;
                    }
                };

                return(inv);
            });

            GuiManager.ShowDialog(dialog);
            ActiveWindow = dialog;

            return(dialog);
        }