Glamourer-related changes.

This commit is contained in:
Ottermandias 2023-07-12 02:45:40 +02:00
parent a7ace8a8c8
commit 9e0c38169f
15 changed files with 184 additions and 90 deletions

View file

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Objects.Enums;
using Newtonsoft.Json.Linq;
@ -17,10 +17,10 @@ public readonly struct ActorIdentifier : IEquatable<ActorIdentifier>
public enum RetainerType : ushort
{
Both = 0,
Bell = 1,
Both = 0,
Bell = 1,
Mannequin = 2,
}
}
// @formatter:off
[FieldOffset( 0 )] public readonly IdentifierType Type; // All
@ -75,7 +75,7 @@ public readonly struct ActorIdentifier : IEquatable<ActorIdentifier>
var parts = name.Split(' ', 3);
return string.Join(" ",
parts.Length != 3 ? parts.Select(n => $"{n[0]}.") : parts[..2].Select(n => $"{n[0]}.").Append(parts[2]));
}
}
public override string ToString()
=> Manager?.ToString(this)
@ -95,6 +95,9 @@ public readonly struct ActorIdentifier : IEquatable<ActorIdentifier>
_ => "Invalid",
};
public string ToName()
=> Manager?.ToName(this) ?? "Unknown Object";
public override int GetHashCode()
=> Type switch
{
@ -217,6 +220,6 @@ public static class ActorManagerExtensions
ScreenActor.FittingRoom => "Fitting Room Actor",
ScreenActor.DyePreview => "Dye Preview Actor",
ScreenActor.Portrait => "Portrait Actor",
_ => "Invalid",
_ => "Invalid",
};
}

View file

@ -91,6 +91,23 @@ public partial class ActorManager
};
}
/// <summary>
/// Use stored data to convert an ActorIdentifier to a name only.
/// </summary>
public string ToName(ActorIdentifier id)
{
return id.Type switch
{
IdentifierType.Player => id.PlayerName.ToString(),
IdentifierType.Retainer => id.PlayerName.ToString(),
IdentifierType.Owned => $"{id.PlayerName}s {Data.ToName(id.Kind, id.DataId)}",
IdentifierType.Special => id.Special.ToName(),
IdentifierType.Npc => Data.ToName(id.Kind, id.DataId),
IdentifierType.UnkObject => id.PlayerName.IsEmpty ? id.PlayerName.ToString() : "Unknown Object",
_ => "Invalid",
};
}
private unsafe FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* HandleCutscene(
FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* main)
{
@ -382,7 +399,7 @@ public partial class ActorManager
public unsafe ActorIdentifier FromObject(GameObject? actor, out FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner,
bool allowPlayerNpc, bool check, bool withoutIndex)
=> FromObject((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)(actor?.Address ?? IntPtr.Zero), out owner, allowPlayerNpc,
check, withoutIndex);
check, withoutIndex);
public unsafe ActorIdentifier FromObject(GameObject? actor, bool allowPlayerNpc, bool check, bool withoutIndex)
=> FromObject(actor, out _, allowPlayerNpc, check, withoutIndex);