diff --git a/Dalamud/Game/Inventory/GameInventory.cs b/Dalamud/Game/Inventory/GameInventory.cs index 4ee66ffaf..5842996b6 100644 --- a/Dalamud/Game/Inventory/GameInventory.cs +++ b/Dalamud/Game/Inventory/GameInventory.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; +using System.Linq; using Dalamud.Configuration.Internal; using Dalamud.Game.Inventory.InventoryChangeArgsTypes; @@ -22,21 +24,20 @@ internal class GameInventory : IDisposable, IServiceType, IGameInventory { private static readonly ModuleLog Log = new("GameInventory"); - private readonly List allEvents = new(); private readonly List addedEvents = new(); private readonly List removedEvents = new(); private readonly List changedEvents = new(); private readonly List movedEvents = new(); - + [ServiceManager.ServiceDependency] private readonly Framework framework = Service.Get(); - + [ServiceManager.ServiceDependency] private readonly DalamudConfiguration dalamudConfiguration = Service.Get(); private readonly GameInventoryType[] inventoryTypes; private readonly GameInventoryItem[]?[] inventoryItems; - + [ServiceManager.ServiceConstructor] private GameInventory() { @@ -59,10 +60,10 @@ internal class GameInventory : IDisposable, IServiceType, IGameInventory public event IGameInventory.InventoryChangedDelegate? ItemRemoved; /// - public event IGameInventory.InventoryChangedDelegate? ItemMoved; + public event IGameInventory.InventoryChangedDelegate? ItemChanged; /// - public event IGameInventory.InventoryChangedDelegate? ItemChanged; + public event IGameInventory.InventoryChangedDelegate? ItemMoved; /// public void Dispose() @@ -111,7 +112,7 @@ internal class GameInventory : IDisposable, IServiceType, IGameInventory Log.Error(e, "Exception during {argType} callback", arg.Type); } } - + private void OnFrameworkUpdate(IFramework framework1) { for (var i = 0; i < this.inventoryTypes.Length; i++) @@ -152,124 +153,135 @@ internal class GameInventory : IDisposable, IServiceType, IGameInventory } // Was there any change? If not, stop further processing. - // Note that... - // * this.movedEvents is not checked; it will be populated after this check. - // * this.allEvents is not checked; it is a temporary list to be used after this check. + // Note that this.movedEvents is not checked; it will be populated after this check. if (this.addedEvents.Count == 0 && this.removedEvents.Count == 0 && this.changedEvents.Count == 0) return; - try + // Broadcast InventoryChangedRaw. + InvokeSafely( + this.InventoryChangedRaw, + new DeferredReadOnlyCollection( + this.addedEvents.Count + + this.removedEvents.Count + + this.changedEvents.Count, + () => Array.Empty() + .Concat(this.addedEvents) + .Concat(this.removedEvents) + .Concat(this.changedEvents))); + + // Resolve changelog for item moved, from 1 added + 1 removed event. + for (var iAdded = this.addedEvents.Count - 1; iAdded >= 0; --iAdded) { - // Broadcast InventoryChangedRaw, if necessary. - if (this.InventoryChangedRaw is not null) + var added = this.addedEvents[iAdded]; + for (var iRemoved = this.removedEvents.Count - 1; iRemoved >= 0; --iRemoved) { - this.allEvents.Clear(); - this.allEvents.EnsureCapacity( - this.addedEvents.Count - + this.removedEvents.Count - + this.changedEvents.Count); - this.allEvents.AddRange(this.addedEvents); - this.allEvents.AddRange(this.removedEvents); - this.allEvents.AddRange(this.changedEvents); - InvokeSafely(this.InventoryChangedRaw, this.allEvents); - } + var removed = this.removedEvents[iRemoved]; + if (added.Item.ItemId != removed.Item.ItemId) + continue; - // Resolve changelog for item moved, from 1 added + 1 removed event. - for (var iAdded = this.addedEvents.Count - 1; iAdded >= 0; --iAdded) + this.movedEvents.Add(new(removed, added)); + + // Remove the reinterpreted entries. + this.addedEvents.RemoveAt(iAdded); + this.removedEvents.RemoveAt(iRemoved); + break; + } + } + + // Resolve changelog for item moved, from 2 changed events. + for (var i = this.changedEvents.Count - 1; i >= 0; --i) + { + var e1 = this.changedEvents[i]; + for (var j = i - 1; j >= 0; --j) { - var added = this.addedEvents[iAdded]; - for (var iRemoved = this.removedEvents.Count - 1; iRemoved >= 0; --iRemoved) - { - var removed = this.removedEvents[iRemoved]; - if (added.Item.ItemId != removed.Item.ItemId) - continue; + var e2 = this.changedEvents[j]; + if (e1.Item.ItemId != e2.Item.ItemId || e1.Item.ItemId != e2.Item.ItemId) + continue; - this.movedEvents.Add(new(removed, added)); - - // Remove the reinterpreted entries. - this.addedEvents.RemoveAt(iAdded); - this.removedEvents.RemoveAt(iRemoved); - break; - } + // move happened, and e2 has an item + if (!e2.Item.IsEmpty) + this.movedEvents.Add(new(e1, e2)); + + // move happened, and e1 has an item + if (!e1.Item.IsEmpty) + this.movedEvents.Add(new(e2, e1)); + + // Remove the reinterpreted entries. Note that i > j. + this.changedEvents.RemoveAt(i); + this.changedEvents.RemoveAt(j); + break; } + } - // Resolve changelog for item moved, from 2 changed events. - for (var i = this.changedEvents.Count - 1; i >= 0; --i) - { - var e1 = this.changedEvents[i]; - for (var j = i - 1; j >= 0; --j) - { - var e2 = this.changedEvents[j]; - if (e1.Item.ItemId != e2.Item.ItemId || e1.Item.ItemId != e2.Item.ItemId) - continue; - - // move happened, and e2 has an item - if (!e2.Item.IsEmpty) - this.movedEvents.Add(new(e1, e2)); - - // move happened, and e1 has an item - if (!e1.Item.IsEmpty) - this.movedEvents.Add(new(e2, e1)); - - // Remove the reinterpreted entries. Note that i > j. - this.changedEvents.RemoveAt(i); - this.changedEvents.RemoveAt(j); - break; - } - } - - // Log only if it matters. - if (this.dalamudConfiguration.LogLevel >= LogEventLevel.Verbose) - { - foreach (var x in this.addedEvents) - Log.Verbose($"{x}"); - - foreach (var x in this.removedEvents) - Log.Verbose($"{x}"); - - foreach (var x in this.changedEvents) - Log.Verbose($"{x}"); - - foreach (var x in this.movedEvents) - Log.Verbose($"{x} (({x.SourceEvent}) + ({x.TargetEvent}))"); - } - - // Broadcast InventoryChanged, if necessary. - if (this.InventoryChanged is not null) - { - this.allEvents.Clear(); - this.allEvents.EnsureCapacity( - this.addedEvents.Count - + this.removedEvents.Count - + this.changedEvents.Count - + this.movedEvents.Count); - this.allEvents.AddRange(this.addedEvents); - this.allEvents.AddRange(this.removedEvents); - this.allEvents.AddRange(this.changedEvents); - this.allEvents.AddRange(this.movedEvents); - InvokeSafely(this.InventoryChanged, this.allEvents); - } - - // Broadcast the rest. + // Log only if it matters. + if (this.dalamudConfiguration.LogLevel <= LogEventLevel.Verbose) + { foreach (var x in this.addedEvents) - InvokeSafely(this.ItemAdded, x); - + Log.Verbose($"{x}"); + foreach (var x in this.removedEvents) - InvokeSafely(this.ItemRemoved, x); - + Log.Verbose($"{x}"); + foreach (var x in this.changedEvents) - InvokeSafely(this.ItemChanged, x); - + Log.Verbose($"{x}"); + foreach (var x in this.movedEvents) - InvokeSafely(this.ItemMoved, x); + Log.Verbose($"{x} (({x.SourceEvent}) + ({x.TargetEvent}))"); } - finally + + // Broadcast the rest. + InvokeSafely( + this.InventoryChanged, + new DeferredReadOnlyCollection( + this.addedEvents.Count + + this.removedEvents.Count + + this.changedEvents.Count + + this.movedEvents.Count, + () => Array.Empty() + .Concat(this.addedEvents) + .Concat(this.removedEvents) + .Concat(this.changedEvents) + .Concat(this.movedEvents))); + + foreach (var x in this.addedEvents) + InvokeSafely(this.ItemAdded, x); + + foreach (var x in this.removedEvents) + InvokeSafely(this.ItemRemoved, x); + + foreach (var x in this.changedEvents) + InvokeSafely(this.ItemChanged, x); + + foreach (var x in this.movedEvents) + InvokeSafely(this.ItemMoved, x); + + // We're done using the lists. Clean them up. + this.addedEvents.Clear(); + this.removedEvents.Clear(); + this.changedEvents.Clear(); + this.movedEvents.Clear(); + } + + /// + /// A view of , so that the number of items + /// contained within can be known in advance, and it can be enumerated multiple times. + /// + /// The type of elements being enumerated. + private class DeferredReadOnlyCollection : IReadOnlyCollection + { + private readonly Func> enumerableGenerator; + + public DeferredReadOnlyCollection(int count, Func> enumerableGenerator) { - this.addedEvents.Clear(); - this.removedEvents.Clear(); - this.changedEvents.Clear(); - this.movedEvents.Clear(); + this.enumerableGenerator = enumerableGenerator; + this.Count = count; } + + public int Count { get; } + + public IEnumerator GetEnumerator() => this.enumerableGenerator().GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => this.enumerableGenerator().GetEnumerator(); } } @@ -313,10 +325,10 @@ internal class GameInventoryPluginScoped : IDisposable, IServiceType, IGameInven public event IGameInventory.InventoryChangedDelegate? ItemRemoved; /// - public event IGameInventory.InventoryChangedDelegate? ItemMoved; + public event IGameInventory.InventoryChangedDelegate? ItemChanged; /// - public event IGameInventory.InventoryChangedDelegate? ItemChanged; + public event IGameInventory.InventoryChangedDelegate? ItemMoved; /// public void Dispose() @@ -325,15 +337,15 @@ internal class GameInventoryPluginScoped : IDisposable, IServiceType, IGameInven this.gameInventoryService.InventoryChangedRaw -= this.OnInventoryChangedRawForward; this.gameInventoryService.ItemAdded -= this.OnInventoryItemAddedForward; this.gameInventoryService.ItemRemoved -= this.OnInventoryItemRemovedForward; - this.gameInventoryService.ItemMoved -= this.OnInventoryItemMovedForward; this.gameInventoryService.ItemChanged -= this.OnInventoryItemChangedForward; - + this.gameInventoryService.ItemMoved -= this.OnInventoryItemMovedForward; + this.InventoryChanged = null; this.InventoryChangedRaw = null; this.ItemAdded = null; this.ItemRemoved = null; - this.ItemMoved = null; this.ItemChanged = null; + this.ItemMoved = null; } private void OnInventoryChangedForward(IReadOnlyCollection events) @@ -341,16 +353,16 @@ internal class GameInventoryPluginScoped : IDisposable, IServiceType, IGameInven private void OnInventoryChangedRawForward(IReadOnlyCollection events) => this.InventoryChangedRaw?.Invoke(events); - + private void OnInventoryItemAddedForward(GameInventoryEvent type, InventoryEventArgs data) => this.ItemAdded?.Invoke(type, data); - + private void OnInventoryItemRemovedForward(GameInventoryEvent type, InventoryEventArgs data) => this.ItemRemoved?.Invoke(type, data); - private void OnInventoryItemMovedForward(GameInventoryEvent type, InventoryEventArgs data) - => this.ItemMoved?.Invoke(type, data); - private void OnInventoryItemChangedForward(GameInventoryEvent type, InventoryEventArgs data) => this.ItemChanged?.Invoke(type, data); + + private void OnInventoryItemMovedForward(GameInventoryEvent type, InventoryEventArgs data) + => this.ItemMoved?.Invoke(type, data); } diff --git a/Dalamud/Game/Inventory/GameInventoryEvent.cs b/Dalamud/Game/Inventory/GameInventoryEvent.cs index c23d79f30..6a4bb86e2 100644 --- a/Dalamud/Game/Inventory/GameInventoryEvent.cs +++ b/Dalamud/Game/Inventory/GameInventoryEvent.cs @@ -3,7 +3,6 @@ /// /// Class representing a item's changelog state. /// -[Flags] public enum GameInventoryEvent { /// @@ -11,24 +10,24 @@ public enum GameInventoryEvent /// You should not see this value, unless you explicitly used it yourself, or APIs using this enum say otherwise. /// Empty = 0, - + /// /// Item was added to an inventory. /// - Added = 1 << 0, - + Added = 1, + /// /// Item was removed from an inventory. /// - Removed = 1 << 1, - + Removed = 2, + /// /// Properties are changed for an item in an inventory. /// - Changed = 1 << 2, - + Changed = 3, + /// /// Item has been moved, possibly across different inventories. /// - Moved = 1 << 3, + Moved = 4, } diff --git a/Dalamud/Game/Inventory/GameInventoryItem.cs b/Dalamud/Game/Inventory/GameInventoryItem.cs index 9073073cb..52a5c5e3c 100644 --- a/Dalamud/Game/Inventory/GameInventoryItem.cs +++ b/Dalamud/Game/Inventory/GameInventoryItem.cs @@ -12,11 +12,6 @@ namespace Dalamud.Game.Inventory; [StructLayout(LayoutKind.Explicit, Size = StructSizeInBytes)] public unsafe struct GameInventoryItem : IEquatable { - /// - /// An empty instance of . - /// - internal static readonly GameInventoryItem Empty = default; - /// /// The actual data. /// @@ -104,7 +99,7 @@ public unsafe struct GameInventoryItem : IEquatable /// Gets the array of materia types. /// public ReadOnlySpan Materia => new(Unsafe.AsPointer(ref Unsafe.AsRef(in this.InternalItem.Materia[0])), 5); - + /// /// Gets the array of materia grades. /// @@ -119,8 +114,8 @@ public unsafe struct GameInventoryItem : IEquatable /// /// Gets the glamour id for this item. /// - public uint GlmaourId => this.InternalItem.GlamourID; - + public uint GlamourId => this.InternalItem.GlamourID; + /// /// Gets the items crafter's content id. /// NOTE: I'm not sure if this is a good idea to include or not in the dalamud api. Marked internal for now. @@ -163,6 +158,6 @@ public unsafe struct GameInventoryItem : IEquatable /// public override string ToString() => this.IsEmpty - ? "" - : $"Item #{this.ItemId} at slot {this.InventorySlot} in {this.ContainerType}"; + ? "no item" + : $"item #{this.ItemId} at slot {this.InventorySlot} in {this.ContainerType}"; } diff --git a/Dalamud/Game/Inventory/GameInventoryType.cs b/Dalamud/Game/Inventory/GameInventoryType.cs index c982fa80f..00c65046f 100644 --- a/Dalamud/Game/Inventory/GameInventoryType.cs +++ b/Dalamud/Game/Inventory/GameInventoryType.cs @@ -9,17 +9,17 @@ public enum GameInventoryType : ushort /// First panel of main player inventory. /// Inventory1 = 0, - + /// /// Second panel of main player inventory. /// Inventory2 = 1, - + /// /// Third panel of main player inventory. /// Inventory3 = 2, - + /// /// Fourth panel of main player inventory. /// @@ -40,32 +40,32 @@ public enum GameInventoryType : ushort /// Crystal container. /// Crystals = 2001, - + /// /// Mail container. /// Mail = 2003, - + /// /// Key item container. /// KeyItems = 2004, - + /// /// Quest item hand-in inventory. /// HandIn = 2005, - + /// /// DamagedGear container. /// DamagedGear = 2007, - + /// /// Examine window container. /// Examine = 2009, - + /// /// Doman Enclave Reconstruction Reclamation Box. /// @@ -75,22 +75,22 @@ public enum GameInventoryType : ushort /// Armory off-hand weapon container. /// ArmoryOffHand = 3200, - + /// /// Armory head container. /// ArmoryHead = 3201, - + /// /// Armory body container. /// ArmoryBody = 3202, - + /// /// Armory hand/gloves container. /// ArmoryHands = 3203, - + /// /// Armory waist container. /// @@ -98,42 +98,42 @@ public enum GameInventoryType : ushort /// /// ArmoryWaist = 3204, - + /// /// Armory legs/pants/skirt container. /// ArmoryLegs = 3205, - + /// /// Armory feet/boots/shoes container. /// ArmoryFeets = 3206, - + /// /// Armory earring container. /// ArmoryEar = 3207, - + /// /// Armory necklace container. /// ArmoryNeck = 3208, - + /// /// Armory bracelet container. /// ArmoryWrist = 3209, - + /// /// Armory ring container. /// ArmoryRings = 3300, - + /// /// Armory soul crystal container. /// ArmorySoulCrystal = 3400, - + /// /// Armory main-hand weapon container. /// @@ -143,17 +143,17 @@ public enum GameInventoryType : ushort /// First panel of saddelbag inventory. /// SaddleBag1 = 4000, - + /// /// Second panel of Saddlebag inventory. /// SaddleBag2 = 4001, - + /// /// First panel of premium saddlebag inventory. /// PremiumSaddleBag1 = 4100, - + /// /// Second panel of premium saddlebag inventory. /// @@ -163,52 +163,52 @@ public enum GameInventoryType : ushort /// First panel of retainer inventory. /// RetainerPage1 = 10000, - + /// /// Second panel of retainer inventory. /// RetainerPage2 = 10001, - + /// /// Third panel of retainer inventory. /// RetainerPage3 = 10002, - + /// /// Fourth panel of retainer inventory. /// RetainerPage4 = 10003, - + /// /// Fifth panel of retainer inventory. /// RetainerPage5 = 10004, - + /// /// Sixth panel of retainer inventory. /// RetainerPage6 = 10005, - + /// /// Seventh panel of retainer inventory. /// RetainerPage7 = 10006, - + /// /// Retainer equipment container. /// RetainerEquippedItems = 11000, - + /// /// Retainer currency container. /// RetainerGil = 12000, - + /// /// Retainer crystal container. /// RetainerCrystals = 12001, - + /// /// Retainer market item container. /// @@ -218,32 +218,32 @@ public enum GameInventoryType : ushort /// First panel of Free Company inventory. /// FreeCompanyPage1 = 20000, - + /// /// Second panel of Free Company inventory. /// FreeCompanyPage2 = 20001, - + /// /// Third panel of Free Company inventory. /// FreeCompanyPage3 = 20002, - + /// /// Fourth panel of Free Company inventory. /// FreeCompanyPage4 = 20003, - + /// /// Fifth panel of Free Company inventory. /// FreeCompanyPage5 = 20004, - + /// /// Free Company currency container. /// FreeCompanyGil = 22000, - + /// /// Free Company crystal container. /// @@ -253,102 +253,102 @@ public enum GameInventoryType : ushort /// Housing exterior appearance container. /// HousingExteriorAppearance = 25000, - + /// /// Housing exterior placed items container. /// HousingExteriorPlacedItems = 25001, - + /// /// Housing interior appearance container. /// HousingInteriorAppearance = 25002, - + /// /// First panel of housing interior inventory. /// HousingInteriorPlacedItems1 = 25003, - + /// /// Second panel of housing interior inventory. /// HousingInteriorPlacedItems2 = 25004, - + /// /// Third panel of housing interior inventory. /// HousingInteriorPlacedItems3 = 25005, - + /// /// Fourth panel of housing interior inventory. /// HousingInteriorPlacedItems4 = 25006, - + /// /// Fifth panel of housing interior inventory. /// HousingInteriorPlacedItems5 = 25007, - + /// /// Sixth panel of housing interior inventory. /// HousingInteriorPlacedItems6 = 25008, - + /// /// Seventh panel of housing interior inventory. /// HousingInteriorPlacedItems7 = 25009, - + /// /// Eighth panel of housing interior inventory. /// HousingInteriorPlacedItems8 = 25010, - + /// /// Housing exterior storeroom inventory. /// HousingExteriorStoreroom = 27000, - + /// /// First panel of housing interior storeroom inventory. /// HousingInteriorStoreroom1 = 27001, - + /// /// Second panel of housing interior storeroom inventory. /// HousingInteriorStoreroom2 = 27002, - + /// /// Third panel of housing interior storeroom inventory. /// HousingInteriorStoreroom3 = 27003, - + /// /// Fourth panel of housing interior storeroom inventory. /// HousingInteriorStoreroom4 = 27004, - + /// /// Fifth panel of housing interior storeroom inventory. /// HousingInteriorStoreroom5 = 27005, - + /// /// Sixth panel of housing interior storeroom inventory. /// HousingInteriorStoreroom6 = 27006, - + /// /// Seventh panel of housing interior storeroom inventory. /// HousingInteriorStoreroom7 = 27007, - + /// /// Eighth panel of housing interior storeroom inventory. /// HousingInteriorStoreroom8 = 27008, - + /// /// An invalid value. /// diff --git a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryEventArgs.cs b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryEventArgs.cs index 070d8a8db..301715bf2 100644 --- a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryEventArgs.cs +++ b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryEventArgs.cs @@ -1,13 +1,12 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Dalamud.Game.Inventory.InventoryChangeArgsTypes; +namespace Dalamud.Game.Inventory.InventoryChangeArgsTypes; /// /// Abstract base class representing inventory changed events. /// -[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1206:Declaration keywords should follow order", Justification = "It literally says , , and then . required is not an access modifier.")] public abstract class InventoryEventArgs { + private readonly GameInventoryItem item; + /// /// Initializes a new instance of the class. /// @@ -16,7 +15,7 @@ public abstract class InventoryEventArgs protected InventoryEventArgs(GameInventoryEvent type, in GameInventoryItem item) { this.Type = type; - this.Item = item; + this.item = item; } /// @@ -28,8 +27,11 @@ public abstract class InventoryEventArgs /// Gets the item associated with this event. /// This is a copy of the item data. /// - public GameInventoryItem Item { get; } - + // impl note: we return a ref readonly view, to avoid making copies every time this property is accessed. + // see: https://devblogs.microsoft.com/premier-developer/avoiding-struct-and-readonly-reference-performance-pitfalls-with-errorprone-net/ + // "Consider using ref readonly locals and ref return for library code" + public ref readonly GameInventoryItem Item => ref this.item; + /// public override string ToString() => $"<{this.Type}> ({this.Item})"; } diff --git a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemChangedArgs.cs b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemChangedArgs.cs index 1c47d3b83..1682ae32d 100644 --- a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemChangedArgs.cs +++ b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemChangedArgs.cs @@ -6,6 +6,8 @@ /// public class InventoryItemChangedArgs : InventoryEventArgs { + private readonly GameInventoryItem oldItemState; + /// /// Initializes a new instance of the class. /// @@ -14,7 +16,7 @@ public class InventoryItemChangedArgs : InventoryEventArgs internal InventoryItemChangedArgs(in GameInventoryItem oldItem, in GameInventoryItem newItem) : base(GameInventoryEvent.Changed, newItem) { - this.OldItemState = oldItem; + this.oldItemState = oldItem; } /// @@ -29,6 +31,8 @@ public class InventoryItemChangedArgs : InventoryEventArgs /// /// Gets the state of the item from before it was changed. + /// This is a copy of the item data. /// - public GameInventoryItem OldItemState { get; init; } + // impl note: see InventoryEventArgs.Item. + public ref readonly GameInventoryItem OldItemState => ref this.oldItemState; } diff --git a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemMovedArgs.cs b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemMovedArgs.cs index 2f1113b02..b6f490a2c 100644 --- a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemMovedArgs.cs +++ b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemMovedArgs.cs @@ -1,11 +1,8 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Dalamud.Game.Inventory.InventoryChangeArgsTypes; +namespace Dalamud.Game.Inventory.InventoryChangeArgsTypes; /// /// Represents the data associated with an item being moved from one inventory and added to another. /// -[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1206:Declaration keywords should follow order", Justification = "It literally says , , and then . required is not an access modifier.")] public class InventoryItemMovedArgs : InventoryEventArgs { /// @@ -29,7 +26,7 @@ public class InventoryItemMovedArgs : InventoryEventArgs /// Gets the inventory this item was moved to. /// public GameInventoryType TargetInventory => this.Item.ContainerType; - + /// /// Gets the slot this item was moved from. /// @@ -49,7 +46,7 @@ public class InventoryItemMovedArgs : InventoryEventArgs /// Gets the associated target event. /// internal InventoryEventArgs TargetEvent { get; } - + /// public override string ToString() => $"<{this.Type}> (Item #{this.Item.ItemId}) from (slot {this.SourceSlot} in {this.SourceInventory}) to (slot {this.TargetSlot} in {this.TargetInventory})"; diff --git a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemRemovedArgs.cs b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemRemovedArgs.cs index bd982d702..41ca9d380 100644 --- a/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemRemovedArgs.cs +++ b/Dalamud/Game/Inventory/InventoryChangeArgsTypes/InventoryItemRemovedArgs.cs @@ -13,12 +13,12 @@ public class InventoryItemRemovedArgs : InventoryEventArgs : base(GameInventoryEvent.Removed, item) { } - + /// /// Gets the inventory this item was removed from. /// public GameInventoryType Inventory => this.Item.ContainerType; - + /// /// Gets the slot this item was removed from. /// diff --git a/Dalamud/Plugin/Services/IGameInventory.cs b/Dalamud/Plugin/Services/IGameInventory.cs index 979e2d6a6..058bcbd27 100644 --- a/Dalamud/Plugin/Services/IGameInventory.cs +++ b/Dalamud/Plugin/Services/IGameInventory.cs @@ -24,12 +24,12 @@ public interface IGameInventory /// The event try that triggered this message. /// Data for the triggered event. public delegate void InventoryChangedDelegate(GameInventoryEvent type, InventoryEventArgs data); - + /// /// Event that is fired when the inventory has been changed. /// public event InventoryChangelogDelegate InventoryChanged; - + /// /// Event that is fired when the inventory has been changed, without trying to interpret two inventory slot changes /// as a move event as appropriate.