using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Component.GUI; namespace Dalamud.Game.Addon.Events; /// /// This class represents a registered event that a plugin registers with a native ui node. /// Contains all necessary information to track and clean up events automatically. /// internal unsafe class AddonEventEntry { /// /// Name of an invalid addon. /// public const string InvalidAddonName = "NullAddon"; private string? addonName; /// /// Gets the pointer to the addons AtkUnitBase. /// public required nint Addon { get; init; } /// /// Gets the name of the addon this args referrers to. /// public string AddonName => this.Addon == nint.Zero ? InvalidAddonName : this.addonName ??= ((AtkUnitBase*)this.Addon)->NameString; /// /// Gets the pointer to the event source. /// public required nint Node { get; init; } /// /// Gets the delegate that gets called when this event is triggered. /// public required IAddonEventManager.AddonEventDelegate Delegate { get; init; } /// /// Gets the unique id for this event. /// public required uint ParamKey { get; init; } /// /// Gets the event type for this event. /// public required AddonEventType EventType { get; init; } /// /// Gets the event handle for this event. /// internal required IAddonEventHandle Handle { get; init; } /// /// Gets the formatted log string for this AddonEventEntry. /// internal string LogString => $"ParamKey: {this.ParamKey}, Addon: {this.AddonName}, Event: {this.EventType}, GUID: {this.Handle.EventGuid}"; }