mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-14 23:58:12 +03:00
InventoryDef properties cache
This commit is contained in:
parent
b6fa05afa2
commit
d40efa8612
@ -8,6 +8,7 @@ namespace Steamworks
|
|||||||
public class InventoryDef
|
public class InventoryDef
|
||||||
{
|
{
|
||||||
internal InventoryDefId _id;
|
internal InventoryDefId _id;
|
||||||
|
internal Dictionary<string, string> _properties;
|
||||||
|
|
||||||
public InventoryDef( InventoryDefId defId )
|
public InventoryDef( InventoryDefId defId )
|
||||||
{
|
{
|
||||||
@ -94,13 +95,22 @@ namespace Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetProperty( string name )
|
public string GetProperty( string name )
|
||||||
{
|
{
|
||||||
|
if ( _properties!= null && _properties.TryGetValue( name, out string val ) )
|
||||||
|
return val;
|
||||||
|
|
||||||
var sb = Helpers.TakeStringBuilder();
|
var sb = Helpers.TakeStringBuilder();
|
||||||
uint _ = (uint)sb.Capacity;
|
uint _ = (uint)sb.Capacity;
|
||||||
|
|
||||||
if ( !SteamInventory.Internal.GetItemDefinitionProperty( Id, name, sb, ref _ ) )
|
if ( !SteamInventory.Internal.GetItemDefinitionProperty( Id, name, sb, ref _ ) )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return sb.ToString();
|
if ( _properties == null )
|
||||||
|
_properties = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
var vl = sb.ToString();
|
||||||
|
_properties[name] = vl;
|
||||||
|
|
||||||
|
return vl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user