Add Inventory.OnInventoryResultReady so you can check that as well as the generic OnUpdate

This commit is contained in:
Rohan Singh 2018-12-04 13:39:31 -05:00
parent 96511dcc64
commit 971751f89d

View File

@ -41,6 +41,8 @@ public partial class Inventory : IDisposable
public event Action OnDefinitionsUpdated; public event Action OnDefinitionsUpdated;
public event Action<Result> OnInventoryResultReady;
internal Inventory( BaseSteamworks steamworks, SteamNative.SteamInventory c, bool server ) internal Inventory( BaseSteamworks steamworks, SteamNative.SteamInventory c, bool server )
{ {
IsServer = server; IsServer = server;
@ -113,10 +115,9 @@ private void onFullUpdate( SteamInventoryFullUpdate_t data )
/// </summary> /// </summary>
private void onResultReady( SteamInventoryResultReady_t data ) private void onResultReady( SteamInventoryResultReady_t data )
{ {
if ( Result.Pending.ContainsKey( data.Handle ) ) Result result;
if ( Result.Pending.TryGetValue( data.Handle, out result ) )
{ {
var result = Result.Pending[data.Handle];
result.OnSteamResult( data ); result.OnSteamResult( data );
if ( data.Result == SteamNative.Result.OK ) if ( data.Result == SteamNative.Result.OK )
@ -127,6 +128,13 @@ private void onResultReady( SteamInventoryResultReady_t data )
Result.Pending.Remove( data.Handle ); Result.Pending.Remove( data.Handle );
result.Dispose(); result.Dispose();
} }
else
{
result = new Result(this, data.Handle, false);
result.Fill();
}
OnInventoryResultReady?.Invoke(result);
} }
private void onResult( Result r, bool isFullUpdate ) private void onResult( Result r, bool isFullUpdate )