mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 15:18:07 +03:00
Don't release inventoryg result in InventoryUpdated callback
This commit is contained in:
parent
69ec868227
commit
7a30b76a26
@ -54,10 +54,13 @@ namespace Steamworks
|
||||
var result = await SteamInventory.GetAllItemsAsync();
|
||||
|
||||
Assert.IsTrue( result.HasValue );
|
||||
Assert.IsTrue( result.Value.ItemCount > 0 );
|
||||
|
||||
using ( result )
|
||||
{
|
||||
var items = result?.GetItems( true );
|
||||
var items = result.Value.GetItems( true );
|
||||
|
||||
Assert.IsNotNull( items );
|
||||
|
||||
foreach ( var item in items )
|
||||
{
|
||||
@ -71,6 +74,33 @@ namespace Steamworks
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task GetAllItemsMultipleTimes()
|
||||
{
|
||||
await SteamInventory.WaitForDefinitions();
|
||||
|
||||
var fresult = await SteamInventory.GetAllItemsAsync();
|
||||
|
||||
Assert.IsTrue( fresult.HasValue );
|
||||
Assert.IsTrue( fresult.Value.ItemCount > 0 );
|
||||
|
||||
await Task.Delay( 1000 );
|
||||
|
||||
var result = await SteamInventory.GetAllItemsAsync();
|
||||
|
||||
Assert.IsTrue( result.HasValue );
|
||||
Assert.IsTrue( result.Value.GetItems().Length == fresult.Value.ItemCount );
|
||||
|
||||
|
||||
await Task.Delay( 1000 );
|
||||
|
||||
result = await SteamInventory.GetAllItemsAsync();
|
||||
|
||||
Assert.IsTrue( result.HasValue );
|
||||
Assert.IsTrue( result.Value.ItemCount == fresult.Value.ItemCount );
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Items()
|
||||
{
|
||||
|
@ -46,8 +46,6 @@ namespace Steamworks
|
||||
Items = r.GetItems( false );
|
||||
|
||||
OnInventoryUpdated?.Invoke( r );
|
||||
|
||||
r.Dispose();
|
||||
}
|
||||
|
||||
public static event Action<InventoryResult> OnInventoryUpdated;
|
||||
|
@ -58,6 +58,8 @@ namespace Steamworks
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if ( _id.Value == -1 ) return;
|
||||
|
||||
SteamInventory.Internal.DestroyResult( _id );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user