Esempio n. 1
0
        public void CrossInventoryExchange(IItemStackSlot @from, IItemStackSlot to)
        {
            IInventory fromInventory = from.Inventory;
            IInventory toInventory   = to.Inventory;

            ItemStack fromStack = fromInventory.RemoveStackAtSlot(from.InventoryIndex);

            if (to.ItemStack.IsEmpty)
            {
                toInventory.AddStackAtSlot(fromStack, to.InventoryIndex);
            }
            else
            {
                ItemStack toStack = toInventory.RemoveStackAtSlot(to.InventoryIndex);

                fromInventory.AddItemStacks(new[] { toInventory.AddStackAtSlot(fromStack, to.InventoryIndex) });
                toInventory.AddItemStacks(new[] { fromInventory.AddStackAtSlot(toStack, from.InventoryIndex) });
            }
        }