From d40efa8612e5ec8c884de77cff0325d4b979dd42 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 7 May 2019 21:11:55 +0100 Subject: [PATCH] InventoryDef properties cache --- Facepunch.Steamworks/Structs/InventoryDef.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Facepunch.Steamworks/Structs/InventoryDef.cs b/Facepunch.Steamworks/Structs/InventoryDef.cs index 4e58754..f93368e 100644 --- a/Facepunch.Steamworks/Structs/InventoryDef.cs +++ b/Facepunch.Steamworks/Structs/InventoryDef.cs @@ -8,6 +8,7 @@ namespace Steamworks public class InventoryDef { internal InventoryDefId _id; + internal Dictionary _properties; public InventoryDef( InventoryDefId defId ) { @@ -94,13 +95,22 @@ public InventoryRecipe[] GetRecipes() /// 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(); + + var vl = sb.ToString(); + _properties[name] = vl; + + return vl; } ///