mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-28 15:45:29 +03:00
Added CraftItemAsync with Amounts
This commit is contained in:
parent
d40efa8612
commit
18f81573f5
@ -239,6 +239,27 @@ public static bool GetAllItems()
|
|||||||
return await InventoryResult.GetAsync( sresult );
|
return await InventoryResult.GetAsync( sresult );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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. This assumes all the items passed in aren't stacked.
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<InventoryResult?> CraftItemAsync( InventoryItem.Amount[] list, InventoryDef target )
|
||||||
|
{
|
||||||
|
var sresult = default( SteamInventoryResult_t );
|
||||||
|
|
||||||
|
var give = new InventoryDefId[] { target.Id };
|
||||||
|
var givec = new uint[] { 1 };
|
||||||
|
|
||||||
|
var sell = list.Select( x => x.Item.Id ).ToArray();
|
||||||
|
var sellc = list.Select( x => (uint) x.Quantity ).ToArray();
|
||||||
|
|
||||||
|
if ( !Internal.ExchangeItems( ref sresult, give, givec, 1, sell, sellc, (uint)sell.Length ) )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return await InventoryResult.GetAsync( sresult );
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deserializes a result set and verifies the signature bytes.
|
/// Deserializes a result set and verifies the signature bytes.
|
||||||
/// This call has a potential soft-failure mode where the Result is expired, it will
|
/// This call has a potential soft-failure mode where the Result is expired, it will
|
||||||
|
@ -122,5 +122,14 @@ internal static Dictionary<string, string> GetProperties( SteamInventoryResult_t
|
|||||||
|
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Small utility class to describe an item with a quantity
|
||||||
|
/// </summary>
|
||||||
|
public struct Amount
|
||||||
|
{
|
||||||
|
public InventoryItem Item;
|
||||||
|
public int Quantity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user