mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
Add enumerable AtkValue helper
This commit is contained in:
parent
2dbae05522
commit
a715725a9d
2 changed files with 56 additions and 4 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using Dalamud.Game.NativeWrapper;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
@ -32,7 +35,30 @@ public class AddonRefreshArgs : AddonArgs
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the AtkValues in the form of a span.
|
/// Gets the AtkValues in the form of a span.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Pending removal, unsafe to use when using custom ClientStructs")]
|
[Obsolete("Pending removal, Use AtkValueEnumerable instead.")]
|
||||||
[Api15ToDo("Remove this")]
|
[Api15ToDo("Make this internal, remove obsolete")]
|
||||||
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount);
|
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an enumerable collection of <see cref="AtkValuePtr"/> of the event's AtkValues.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// An <see cref="IEnumerable{T}"/> of <see cref="AtkValuePtr"/> corresponding to the event's AtkValues.
|
||||||
|
/// </returns>
|
||||||
|
public IEnumerable<AtkValuePtr> AtkValueEnumerable
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
for (var i = 0; i < this.AtkValueCount; i++)
|
||||||
|
{
|
||||||
|
AtkValuePtr ptr;
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
ptr = new AtkValuePtr((nint)this.AtkValueSpan[i].Pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using Dalamud.Game.NativeWrapper;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
@ -32,7 +35,30 @@ public class AddonSetupArgs : AddonArgs
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the AtkValues in the form of a span.
|
/// Gets the AtkValues in the form of a span.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Pending removal, unsafe to use when using custom ClientStructs")]
|
[Obsolete("Pending removal, Use AtkValueEnumerable instead.")]
|
||||||
[Api15ToDo("Remove this")]
|
[Api15ToDo("Make this internal, remove obsolete")]
|
||||||
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount);
|
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an enumerable collection of <see cref="AtkValuePtr"/> of the event's AtkValues.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// An <see cref="IEnumerable{T}"/> of <see cref="AtkValuePtr"/> corresponding to the event's AtkValues.
|
||||||
|
/// </returns>
|
||||||
|
public IEnumerable<AtkValuePtr> AtkValueEnumerable
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
for (var i = 0; i < this.AtkValueCount; i++)
|
||||||
|
{
|
||||||
|
AtkValuePtr ptr;
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
ptr = new AtkValuePtr((nint)this.AtkValueSpan[i].Pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue