示例#1
0
 private void SaveSlotState()
 {
     foreach (KeyValuePair <Item.ItemType, GUILabeledSlotArray> kvPair in subInvSlots)
     {
         kvPair.Value.SaveToInventory(subInventories[kvPair.Key]);
     }
     player.ItemInHand = handSlot.GetCurItemStack();
 }
示例#2
0
    public override void HandleClose()
    {
        Visible = false;
        base.HandleClose();
        SaveSlotState();
        ItemStack stack = floatingSlot.GetCurItemStack();

        if (stack != null)
        {
            subInventories[stack.Item.IType].TryAddItemStack(stack);
            floatingSlot.ClearItemStack();
        }
    }
    public override void OnLeftPress()
    {
        ItemStack exchangeStack = exchangeSlot.GetCurItemStack();
        ItemStack slotStack     = GetCurItemStack();

        if (quickMoveItem != null && slotStack != null && Input.IsActionPressed("quick_move_items"))
        {
            if (quickMoveItem(slotStack))
            {
                ClearItemStack();
                invUpdate?.Invoke();
            }
            return;
        }

        if (exchangeStack != null &&
            !Item.CompatibleWith(exchangeStack.Item.IType, this.GetItemType()))
        {
            return;
        }

        if (slotStack != null &&
            !Item.CompatibleWith(slotStack.Item.IType, exchangeSlot.GetItemType()))
        {
            return;
        }

        // TODO: think of a better conditional
        if (exchangeStack != null && slotStack != null && slotStack.Item.Stackable && slotStack.Item.Id == exchangeStack.Item.Id)
        {
            slotStack.ChangeQuantity(exchangeStack.Count);
            exchangeSlot.ClearItemStack();
        }
        else
        {
            exchangeSlot.AssignItemStack(slotStack);
            this.AssignItemStack(exchangeStack);
        }
    }