diff --git a/Facepunch.Steamworks/Interfaces/Inventory.Item.cs b/Facepunch.Steamworks/Interfaces/Inventory.Item.cs index f85754e..2240ee3 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.Item.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.Item.cs @@ -64,6 +64,33 @@ namespace Facepunch.Steamworks return !c1.Equals( c2 ); } + /// + /// Consumes items from a user's inventory. If the quantity of the given item goes to zero, it is permanently removed. + /// Once an item is removed it cannot be recovered.This is not for the faint of heart - if your game implements item removal at all, + /// a high-friction UI confirmation process is highly recommended.ConsumeItem can be restricted to certain item definitions or fully + /// blocked via the Steamworks website to minimize support/abuse issues such as the classic "my brother borrowed my laptop and deleted all of my rare items". + /// + public Result Consume( int amount = 1 ) + { + SteamNative.SteamInventoryResult_t resultHandle = -1; + if ( !Definition.inventory.inventory.ConsumeItem( ref resultHandle, Id, (uint)amount ) ) + return null; + + return new Result( Definition.inventory, resultHandle, true ); + } + + /// + /// Split stack into two items + /// + public Result SplitStack( int quantity = 1 ) + { + SteamNative.SteamInventoryResult_t resultHandle = -1; + if ( !Definition.inventory.inventory.TransferItemQuantity( ref resultHandle, Id, (uint)quantity, ulong.MaxValue ) ) + return null; + + return new Result( Definition.inventory, resultHandle, true ); + } + SteamNative.SteamInventoryUpdateHandle_t updateHandle; private void UpdatingProperties() diff --git a/Facepunch.Steamworks/Interfaces/Inventory.cs b/Facepunch.Steamworks/Interfaces/Inventory.cs index 1f1dbe3..2245fcf 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.cs @@ -360,11 +360,7 @@ namespace Facepunch.Steamworks /// 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, true ); + return item.SplitStack( quantity ); } ///