mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-26 13:38:06 +03:00
Added a Inventory.CraftItem version which allows you to specify stack amounts
This commit is contained in:
parent
b06411c42c
commit
287744fd83
@ -13,6 +13,12 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public struct Item : IEquatable<Item>
|
public struct Item : IEquatable<Item>
|
||||||
{
|
{
|
||||||
|
public struct Amount
|
||||||
|
{
|
||||||
|
public Item Item;
|
||||||
|
public int Quantity;
|
||||||
|
}
|
||||||
|
|
||||||
public ulong Id;
|
public ulong Id;
|
||||||
public int Quantity;
|
public int Quantity;
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ namespace Facepunch.Steamworks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Crafting! Uses the passed items to buy the target item.
|
/// Crafting! Uses the passed items to buy the target item.
|
||||||
/// You need to have set up the appropriate exchange rules in your item
|
/// You need to have set up the appropriate exchange rules in your item
|
||||||
/// definitions.
|
/// definitions. This assumes all the items passed in aren't stacked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Result CraftItem( Item[] list, Definition target )
|
public Result CraftItem( Item[] list, Definition target )
|
||||||
{
|
{
|
||||||
@ -316,6 +316,27 @@ namespace Facepunch.Steamworks
|
|||||||
return new Result( this, resultHandle, true );
|
return new Result( this, resultHandle, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Crafting! Uses the passed items to buy the target item.
|
||||||
|
/// You need to have set up the appropriate exchange rules in your item
|
||||||
|
/// definitions.
|
||||||
|
/// </summary>
|
||||||
|
public Result CraftItem( Item.Amount[] list, Definition target )
|
||||||
|
{
|
||||||
|
SteamNative.SteamInventoryResult_t resultHandle = -1;
|
||||||
|
|
||||||
|
var newItems = new SteamNative.SteamItemDef_t[] { new SteamNative.SteamItemDef_t() { Value = target.Id } };
|
||||||
|
var newItemC = new uint[] { 1 };
|
||||||
|
|
||||||
|
var takeItems = list.Select( x => (SteamNative.SteamItemInstanceID_t)x.Item.Id ).ToArray();
|
||||||
|
var takeItemsC = list.Select( x => (uint)x.Quantity ).ToArray();
|
||||||
|
|
||||||
|
if ( !inventory.ExchangeItems( ref resultHandle, newItems, newItemC, 1, takeItems, takeItemsC, (uint)takeItems.Length ) )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new Result( this, resultHandle, true );
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Split stack into two items
|
/// Split stack into two items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user