From f06b4b431badecb8201f83433310b60e6ca8e2e6 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 16 May 2019 15:02:16 +0100 Subject: [PATCH] InventoryItem.Flags uses SteamItemFlags --- Facepunch.Steamworks.Test/InventoryTest.cs | 2 +- Facepunch.Steamworks/Structs/InventoryItem.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Facepunch.Steamworks.Test/InventoryTest.cs b/Facepunch.Steamworks.Test/InventoryTest.cs index 44f5d64..27f04fe 100644 --- a/Facepunch.Steamworks.Test/InventoryTest.cs +++ b/Facepunch.Steamworks.Test/InventoryTest.cs @@ -64,7 +64,7 @@ namespace Steamworks foreach ( var item in items ) { - Console.WriteLine( $"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def?.Name} " ); + Console.WriteLine( $"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def?.Name} /[{item.IsNoTrade}|{item.IsRemoved}|{item.IsConsumed}] " ); foreach ( var prop in item.Properties ) { diff --git a/Facepunch.Steamworks/Structs/InventoryItem.cs b/Facepunch.Steamworks/Structs/InventoryItem.cs index ff0b36a..4dfacc0 100644 --- a/Facepunch.Steamworks/Structs/InventoryItem.cs +++ b/Facepunch.Steamworks/Structs/InventoryItem.cs @@ -9,7 +9,7 @@ namespace Steamworks { internal InventoryItemId _id; internal InventoryDefId _def; - internal int _flags; + internal SteamItemFlags _flags; internal ushort _quantity; internal Dictionary _properties; @@ -31,19 +31,19 @@ namespace Steamworks /// This item is account-locked and cannot be traded or given away. /// This is an item status flag which is permanently attached to specific item instances /// - public bool IsNoTrade => (_flags & 1 << 0) != 0; + public bool IsNoTrade => _flags.HasFlag( SteamItemFlags.NoTrade ); /// /// The item has been destroyed, traded away, expired, or otherwise invalidated. /// This is an action confirmation flag which is only set one time, as part of a result set. /// - public bool IsRemoved => (_flags & 1 << 8) != 0; + public bool IsRemoved => _flags.HasFlag( SteamItemFlags.Removed ); /// /// The item quantity has been decreased by 1 via ConsumeItem API. /// This is an action confirmation flag which is only set one time, as part of a result set. /// - public bool IsConsumed => (_flags & 1 << 9) != 0; + public bool IsConsumed => _flags.HasFlag( SteamItemFlags.Consumed ); /// /// Consumes items from a user's inventory. If the quantity of the given item goes to zero, it is permanently removed. @@ -91,7 +91,7 @@ namespace Steamworks { _id = details.ItemId, _def = details.Definition, - _flags = details.Flags, + _flags = (SteamItemFlags) details.Flags, _quantity = details.Quantity };