using System.Runtime.InteropServices; using FFXIVClientStructs.FFXIV.Client.UI; namespace Dalamud.Game.NativeWrapper; /// /// A readonly wrapper for UIModule. /// /// The address to the UIModule. [StructLayout(LayoutKind.Explicit, Size = 0x08)] public readonly unsafe struct UIModulePtr(nint address) : IEquatable { /// /// The address to the UIModule. /// [FieldOffset(0x00)] public readonly nint Address = address; /// /// Gets a value indicating whether the underlying pointer is a nullptr. /// public readonly bool IsNull => this.Address == 0; /// /// Gets the UIModule*. /// /// Internal use only. internal readonly UIModule* Struct => (UIModule*)this.Address; public static implicit operator nint(UIModulePtr wrapper) => wrapper.Address; public static implicit operator UIModulePtr(nint address) => new(address); public static implicit operator UIModulePtr(void* ptr) => new((nint)ptr); public static bool operator ==(UIModulePtr left, UIModulePtr right) => left.Address == right.Address; public static bool operator !=(UIModulePtr left, UIModulePtr right) => left.Address != right.Address; /// Determines whether the specified UIModulePtr is equal to the current UIModulePtr. /// The UIModulePtr to compare with the current UIModulePtr. /// true if the specified UIModulePtr is equal to the current UIModulePtr; otherwise, false. public readonly bool Equals(UIModulePtr other) => this.Address == other.Address; /// public override readonly bool Equals(object obj) => obj is UIModulePtr wrapper && this.Equals(wrapper); /// public override readonly int GetHashCode() => ((nuint)this.Address).GetHashCode(); }