Add Inventory.EnableItemProperties to turn off per-item properties (not all games need it and it's a bit slow)

There could be a whitelist Func or something added later for more control if anyone wants to do that
This commit is contained in:
Rohan Singh 2018-12-06 15:20:30 -05:00
parent 6c4a83800a
commit 12e26e3f5d
3 changed files with 13 additions and 2 deletions

View File

@ -116,6 +116,9 @@ public Result SplitStack( int quantity = 1 )
private void UpdatingProperties()
{
if (!Inventory.EnableItemProperties)
throw new InvalidOperationException("Item properties are disabled.");
if (updateHandle != 0) return;
updateHandle = Inventory.inventory.StartUpdateProperties();

View File

@ -185,10 +185,12 @@ public void Dispose()
internal Item ItemFrom( SteamInventoryResult_t handle, SteamItemDetails_t detail, int index )
{
var props = new Dictionary<string, string>();
Dictionary<string, string> props = null;
if ( inventory.GetResultItemProperty(handle, (uint) index, null, out string propertyNames) )
if ( EnableItemProperties && inventory.GetResultItemProperty(handle, (uint) index, null, out string propertyNames) )
{
props = new Dictionary<string, string>();
foreach ( var propertyName in propertyNames.Split( ',' ) )
{
if ( inventory.GetResultItemProperty(handle, (uint)index, propertyName, out string propertyValue ) )

View File

@ -33,6 +33,12 @@ public partial class Inventory : IDisposable
/// </summary>
public DateTime SerializedExpireTime;
/// <summary>
/// Controls whether per-item properties (<see cref="Item.Properties"/>) are available or not. Default true.
/// This can improve performance of full inventory updates.
/// </summary>
public bool EnableItemProperties = true;
internal uint LastTimestamp = 0;
internal SteamNative.SteamInventory inventory;