From 971751f89d593cf84b3d65468115cb96a9f38ddf Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Tue, 4 Dec 2018 13:39:31 -0500 Subject: [PATCH] Add Inventory.OnInventoryResultReady so you can check that as well as the generic OnUpdate --- Facepunch.Steamworks/Interfaces/Inventory.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Facepunch.Steamworks/Interfaces/Inventory.cs b/Facepunch.Steamworks/Interfaces/Inventory.cs index a6d00bf..f612708 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.cs @@ -41,6 +41,8 @@ public partial class Inventory : IDisposable public event Action OnDefinitionsUpdated; + public event Action OnInventoryResultReady; + internal Inventory( BaseSteamworks steamworks, SteamNative.SteamInventory c, bool server ) { IsServer = server; @@ -113,10 +115,9 @@ private void onFullUpdate( SteamInventoryFullUpdate_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 ); if ( data.Result == SteamNative.Result.OK ) @@ -127,6 +128,13 @@ private void onResultReady( SteamInventoryResultReady_t data ) Result.Pending.Remove( data.Handle ); result.Dispose(); } + else + { + result = new Result(this, data.Handle, false); + result.Fill(); + } + + OnInventoryResultReady?.Invoke(result); } private void onResult( Result r, bool isFullUpdate )