Ejemplo n.º 1
0
    public void OnCloseSplitMenuUse(GridItem item, int quantity)
    {
        if (quantity > 0 && quantity <= item.GetQuantity())
        {
            //perform consumption. If consumption successful, reduce item quantity and hide panel
            if (GameManager.Inst.PlayerControl.Survival.UseItem(item.Item, quantity))
            {
                int existingQuantity = item.GetQuantity();
                item.SetQuantity(existingQuantity - quantity);
                _windowPanel.SplitItemPanel.Hide();

                if (existingQuantity <= quantity)
                {
                    InventoryGrid parentGrid = item.GetParentGrid();
                    if (parentGrid != null)
                    {
                        parentGrid.RemoveGridItem(item);
                    }
                    DestroyItem(item);
                }
            }
        }
    }