mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Added Inventory.StartPurchase
This commit is contained in:
parent
2da780df7c
commit
796fd29e32
@ -399,6 +399,37 @@ public Result GenerateItem( Definition target, int amount )
|
||||
|
||||
return new Result( this, resultHandle, true );
|
||||
}
|
||||
|
||||
public delegate void StartPurchaseSuccess( ulong orderId, ulong transactionId );
|
||||
|
||||
/// <summary>
|
||||
/// Starts the purchase process for the user, given a "shopping cart" of item definitions that the user would like to buy.
|
||||
/// The user will be prompted in the Steam Overlay to complete the purchase in their local currency, funding their Steam Wallet if necessary, etc.
|
||||
///
|
||||
/// If was succesful the callback orderId and transactionId will be non 0
|
||||
/// </summary>
|
||||
public bool StartPurchase( Definition[] items, StartPurchaseSuccess callback = null )
|
||||
{
|
||||
var itemGroup = items.GroupBy(x => x.Id);
|
||||
|
||||
var newItems = itemGroup.Select( x => new SteamItemDef_t { Value = x.Key } ).ToArray();
|
||||
var newItemC = itemGroup.Select( x => (uint) x.Count() ).ToArray();
|
||||
|
||||
var h = inventory.StartPurchase( newItems, newItemC, (uint) newItemC.Length, ( result, error ) =>
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
callback?.Invoke(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(result.OrderID, result.TransID);
|
||||
}
|
||||
});
|
||||
|
||||
return h != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This might be null until Steam has actually recieved the prices.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user