From 88e2568e9f5d820a67fb5aec7aa39e612f7ceaf4 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 17 Nov 2016 14:08:26 +0000 Subject: [PATCH] Item stacking, unstacking --- Facepunch.Steamworks/Interfaces/Inventory.cs | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Facepunch.Steamworks/Interfaces/Inventory.cs b/Facepunch.Steamworks/Interfaces/Inventory.cs index d48f5c0..611ac5f 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.cs @@ -223,5 +223,29 @@ namespace Facepunch.Steamworks return new Result( this, resultHandle ); } + + /// + /// Split stack into two items + /// + public Result SplitStack( Item item, int quantity = 1 ) + { + SteamNative.SteamInventoryResult_t resultHandle = -1; + if ( !inventory.TransferItemQuantity( ref resultHandle, item.Id, (uint)quantity, ulong.MaxValue ) ) + return null; + + return new Result( this, resultHandle ); + } + + /// + /// Stack source item onto dest item + /// + public Result Stack( Item source, Item dest, int quantity = 1 ) + { + SteamNative.SteamInventoryResult_t resultHandle = -1; + if ( !inventory.TransferItemQuantity( ref resultHandle, source.Id, (uint)quantity, dest.Id ) ) + return null; + + return new Result( this, resultHandle ); + } } }