mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-31 21:03:48 +01:00
Rework ResolveData.
This commit is contained in:
parent
75182d094b
commit
d12a3dd152
14 changed files with 199 additions and 170 deletions
46
Penumbra/Collections/ResolveData.cs
Normal file
46
Penumbra/Collections/ResolveData.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
|
||||
namespace Penumbra.Collections;
|
||||
|
||||
public readonly struct ResolveData
|
||||
{
|
||||
public static readonly ResolveData Invalid = new(ModCollection.Empty);
|
||||
|
||||
public readonly ModCollection ModCollection;
|
||||
public readonly IntPtr AssociatedGameObject;
|
||||
|
||||
public bool Valid
|
||||
=> ModCollection != ModCollection.Empty;
|
||||
|
||||
public ResolveData()
|
||||
{
|
||||
ModCollection = ModCollection.Empty;
|
||||
AssociatedGameObject = IntPtr.Zero;
|
||||
}
|
||||
|
||||
public ResolveData( ModCollection collection, IntPtr gameObject )
|
||||
{
|
||||
ModCollection = collection;
|
||||
AssociatedGameObject = gameObject;
|
||||
}
|
||||
|
||||
public ResolveData( ModCollection collection )
|
||||
: this( collection, IntPtr.Zero )
|
||||
{ }
|
||||
|
||||
public override string ToString()
|
||||
=> ModCollection.Name;
|
||||
}
|
||||
|
||||
public static class ResolveDataExtensions
|
||||
{
|
||||
public static ResolveData ToResolveData( this ModCollection collection )
|
||||
=> new(collection);
|
||||
|
||||
public static ResolveData ToResolveData( this ModCollection collection, IntPtr ptr )
|
||||
=> new(collection, ptr);
|
||||
|
||||
public static unsafe ResolveData ToResolveData( this ModCollection collection, void* ptr )
|
||||
=> new(collection, ( IntPtr )ptr);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue