diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs index 8af017318..cb9de8088 100644 --- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs +++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; + +using Dalamud.Game.NativeWrapper; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Component.GUI; @@ -32,7 +35,30 @@ public class AddonRefreshArgs : AddonArgs /// /// Gets the AtkValues in the form of a span. /// - [Obsolete("Pending removal, unsafe to use when using custom ClientStructs")] - [Api15ToDo("Remove this")] + [Obsolete("Pending removal, Use AtkValueEnumerable instead.")] + [Api15ToDo("Make this internal, remove obsolete")] public unsafe Span AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount); + + /// + /// Gets an enumerable collection of of the event's AtkValues. + /// + /// + /// An of corresponding to the event's AtkValues. + /// + public IEnumerable AtkValueEnumerable + { + get + { + for (var i = 0; i < this.AtkValueCount; i++) + { + AtkValuePtr ptr; + unsafe + { + ptr = new AtkValuePtr((nint)this.AtkValueSpan[i].Pointer); + } + + yield return ptr; + } + } + } } diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs index 9fd7b6dd0..2501d159f 100644 --- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs +++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; + +using Dalamud.Game.NativeWrapper; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Component.GUI; @@ -32,7 +35,30 @@ public class AddonSetupArgs : AddonArgs /// /// Gets the AtkValues in the form of a span. /// - [Obsolete("Pending removal, unsafe to use when using custom ClientStructs")] - [Api15ToDo("Remove this")] + [Obsolete("Pending removal, Use AtkValueEnumerable instead.")] + [Api15ToDo("Make this internal, remove obsolete")] public unsafe Span AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount); + + /// + /// Gets an enumerable collection of of the event's AtkValues. + /// + /// + /// An of corresponding to the event's AtkValues. + /// + public IEnumerable AtkValueEnumerable + { + get + { + for (var i = 0; i < this.AtkValueCount; i++) + { + AtkValuePtr ptr; + unsafe + { + ptr = new AtkValuePtr((nint)this.AtkValueSpan[i].Pointer); + } + + yield return ptr; + } + } + } }