mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 07:05:50 +03:00
Added SteamInventory.StartPurchaseAsync
This commit is contained in:
parent
cad7edcec0
commit
e4c9e9d034
@ -347,5 +347,26 @@ public static bool GetAllItems()
|
||||
return await InventoryResult.GetAsync( sresult );
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Start buying a cart load of items. This will return a positive result is the purchase has
|
||||
/// begun. You should listen out for SteamUser.OnMicroTxnAuthorizationResponse for a success.
|
||||
/// </summary>
|
||||
public static async Task<InventoryPurchaseResult?> StartPurchaseAsync( InventoryDef[] items )
|
||||
{
|
||||
var item_i = items.Select( x => x._id ).ToArray();
|
||||
var item_q = items.Select( x => (uint)1 ).ToArray();
|
||||
|
||||
var r = await Internal.StartPurchase( item_i, item_q, (uint)item_i.Length );
|
||||
if ( !r.HasValue ) return null;
|
||||
|
||||
return new InventoryPurchaseResult
|
||||
{
|
||||
Result = r.Value.Result,
|
||||
OrderID = r.Value.OrderID,
|
||||
TransID = r.Value.TransID
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
16
Facepunch.Steamworks/Structs/InventoryPurchaseResult.cs
Normal file
16
Facepunch.Steamworks/Structs/InventoryPurchaseResult.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
public struct InventoryPurchaseResult
|
||||
{
|
||||
public Result Result;
|
||||
public ulong OrderID;
|
||||
public ulong TransID;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user