mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Inventory item def
This commit is contained in:
parent
1625268f5d
commit
b74d45814a
@ -61,7 +61,7 @@ public async Task GetAllItems()
|
|||||||
|
|
||||||
foreach ( var item in items )
|
foreach ( var item in items )
|
||||||
{
|
{
|
||||||
Console.WriteLine( $"{item.Id} / {item.DefId} / {item.Quantity} " );
|
Console.WriteLine( $"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def.Name} " );
|
||||||
|
|
||||||
foreach ( var prop in item.Properties )
|
foreach ( var prop in item.Properties )
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,17 @@ internal static void InstallEvents()
|
|||||||
internal static void DefinitionsUpdated()
|
internal static void DefinitionsUpdated()
|
||||||
{
|
{
|
||||||
Definitions = GetDefinitions();
|
Definitions = GetDefinitions();
|
||||||
|
|
||||||
|
if ( Definitions != null )
|
||||||
|
{
|
||||||
|
_defMap = new Dictionary<int, InventoryDef>();
|
||||||
|
|
||||||
|
foreach ( var d in Definitions )
|
||||||
|
{
|
||||||
|
_defMap[d.Id] = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defUpdateCount++;
|
defUpdateCount++;
|
||||||
|
|
||||||
OnDefinitionsUpdated?.Invoke();
|
OnDefinitionsUpdated?.Invoke();
|
||||||
@ -76,6 +87,14 @@ public static async Task<bool> WaitForDefinitions( float timeoutSeconds = 10 )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static InventoryDef FindDefinition( InventoryDefId defId )
|
||||||
|
{
|
||||||
|
if ( _defMap.TryGetValue( defId, out var val ) )
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static string Currency { get; internal set; }
|
public static string Currency { get; internal set; }
|
||||||
|
|
||||||
public static async Task<InventoryDef[]> GetDefinitionsWithPricesAsync()
|
public static async Task<InventoryDef[]> GetDefinitionsWithPricesAsync()
|
||||||
@ -103,6 +122,7 @@ public static async Task<InventoryDef[]> GetDefinitionsWithPricesAsync()
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static InventoryDef[] Definitions { get; internal set; }
|
public static InventoryDef[] Definitions { get; internal set; }
|
||||||
|
public static Dictionary<int, InventoryDef> _defMap;
|
||||||
|
|
||||||
internal static InventoryDef[] GetDefinitions()
|
internal static InventoryDef[] GetDefinitions()
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace Steamworks
|
namespace Steamworks
|
||||||
{
|
{
|
||||||
public struct InventoryDef
|
public class InventoryDef
|
||||||
{
|
{
|
||||||
internal InventoryDefId _id;
|
internal InventoryDefId _id;
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ public struct InventoryItem
|
|||||||
|
|
||||||
public int Quantity => _quantity;
|
public int Quantity => _quantity;
|
||||||
|
|
||||||
|
public InventoryDef Def => SteamInventory.FindDefinition( DefId );
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only available if the result set was created with the getproperties
|
/// Only available if the result set was created with the getproperties
|
||||||
|
@ -21,7 +21,7 @@ internal async Task<bool> WaitUntilReadyAsync()
|
|||||||
while ( _result == Result.Pending )
|
while ( _result == Result.Pending )
|
||||||
{
|
{
|
||||||
_result = SteamInventory.Internal.GetResultStatus( _id );
|
_result = SteamInventory.Internal.GetResultStatus( _id );
|
||||||
Task.Delay( 10 );
|
await Task.Delay( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return _result == Result.OK || _result == Result.Expired;
|
return _result == Result.OK || _result == Result.Expired;
|
||||||
|
Loading…
Reference in New Issue
Block a user