InventoryDef properties cache

This commit is contained in:
Garry Newman 2019-05-07 21:11:55 +01:00
parent b6fa05afa2
commit d40efa8612

View File

@ -8,6 +8,7 @@ namespace Steamworks
public class InventoryDef
{
internal InventoryDefId _id;
internal Dictionary<string, string> _properties;
public InventoryDef( InventoryDefId defId )
{
@ -94,13 +95,22 @@ public InventoryRecipe[] GetRecipes()
/// </summary>
public string GetProperty( string name )
{
if ( _properties!= null && _properties.TryGetValue( name, out string val ) )
return val;
var sb = Helpers.TakeStringBuilder();
uint _ = (uint)sb.Capacity;
if ( !SteamInventory.Internal.GetItemDefinitionProperty( Id, name, sb, ref _ ) )
return null;
return sb.ToString();
if ( _properties == null )
_properties = new Dictionary<string, string>();
var vl = sb.ToString();
_properties[name] = vl;
return vl;
}
/// <summary>