mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Disambiguate ObjectId to GameObjectId and EntityId
This commit is contained in:
parent
61f47449fd
commit
8d5f2bdf51
6 changed files with 23 additions and 18 deletions
|
|
@ -83,16 +83,16 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public GameObject? SearchById(ulong objectId)
|
||||
public GameObject? SearchById(ulong gameObjectId)
|
||||
{
|
||||
_ = this.WarnMultithreadedUsage();
|
||||
|
||||
if (objectId is GameObject.InvalidGameObjectId or 0)
|
||||
if (gameObjectId is 0)
|
||||
return null;
|
||||
|
||||
foreach (var e in this.cachedObjectTable)
|
||||
{
|
||||
if (e.Update() is { } o && o.ObjectId == objectId)
|
||||
if (e.Update() is { } o && o.GameObjectId == gameObjectId)
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,6 @@ namespace Dalamud.Game.ClientState.Objects.Types;
|
|||
/// </summary>
|
||||
public unsafe partial class GameObject : IEquatable<GameObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// IDs of non-networked GameObjects.
|
||||
/// </summary>
|
||||
public const uint InvalidGameObjectId = 0xE0000000;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameObject"/> class.
|
||||
/// </summary>
|
||||
|
|
@ -79,13 +74,13 @@ public unsafe partial class GameObject : IEquatable<GameObject>
|
|||
public bool IsValid() => IsValid(this);
|
||||
|
||||
/// <inheritdoc/>
|
||||
bool IEquatable<GameObject>.Equals(GameObject other) => this.ObjectId == other?.ObjectId;
|
||||
bool IEquatable<GameObject>.Equals(GameObject other) => this.GameObjectId == other?.GameObjectId;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => ((IEquatable<GameObject>)this).Equals(obj as GameObject);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode() => this.ObjectId.GetHashCode();
|
||||
public override int GetHashCode() => this.GameObjectId.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -99,10 +94,20 @@ public unsafe partial class GameObject
|
|||
public SeString Name => MemoryHelper.ReadSeString((nint)Unsafe.AsPointer(ref this.Struct->Name[0]), 64);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object ID of this <see cref="GameObject" />.
|
||||
/// Gets the GameObjectID for this GameObject. The Game Object ID is a globally unique identifier that points to
|
||||
/// this specific object. This ID is used to reference specific objects on the local client (e.g. for targeting).
|
||||
///
|
||||
/// Not to be confused with <see cref="EntityId"/>.
|
||||
/// </summary>
|
||||
public uint ObjectId => this.Struct->EntityId;
|
||||
public ulong GameObjectId => this.Struct->GetObjectId();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Entity ID for this GameObject. Entity IDs are assigned to networked GameObjects.
|
||||
///
|
||||
/// A value of <c>0xE000_0000</c> indicates that this entity is not networked and has specific interactivity rules.
|
||||
/// </summary>
|
||||
public uint EntityId => this.Struct->EntityId;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data ID for linking to other respective game data.
|
||||
/// </summary>
|
||||
|
|
@ -185,5 +190,5 @@ public unsafe partial class GameObject
|
|||
protected internal FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)this.Address;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString() => $"{this.ObjectId:X}({this.Name.TextValue} - {this.ObjectKind}) at {this.Address:X}";
|
||||
public override string ToString() => $"{this.GameObjectId:X}({this.Name.TextValue} - {this.ObjectKind}) at {this.Address:X}";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ internal class ObjectTableWidget : IDataWindowWidget
|
|||
// So, while WorldToScreen will return false if the point is off of game client screen, to
|
||||
// to avoid performance issues, we have to manually determine if creating a window would
|
||||
// produce a new viewport, and skip rendering it if so
|
||||
var objectText = $"{obj.Address.ToInt64():X}:{obj.ObjectId:X}[{i}] - {obj.ObjectKind} - {obj.Name}";
|
||||
var objectText = $"{obj.Address.ToInt64():X}:{obj.GameObjectId:X}[{i}] - {obj.ObjectKind} - {obj.Name}";
|
||||
|
||||
var screenPos = ImGui.GetMainViewport().Pos;
|
||||
var screenSize = ImGui.GetMainViewport().Size;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ internal class PartyListWidget : IDataWindowWidget
|
|||
continue;
|
||||
}
|
||||
|
||||
ImGui.Text($"[{i}] {member.Address.ToInt64():X} - {member.Name} - {member.GameObject?.ObjectId}");
|
||||
ImGui.Text($"[{i}] {member.Address.ToInt64():X} - {member.Name} - {member.GameObject?.GameObjectId}");
|
||||
if (this.resolveGameData)
|
||||
{
|
||||
var actor = member.GameObject;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ public interface IObjectTable : IEnumerable<GameObject>
|
|||
/// <summary>
|
||||
/// Search for a game object by their Object ID.
|
||||
/// </summary>
|
||||
/// <param name="objectId">Object ID to find.</param>
|
||||
/// <param name="gameObjectId">Object ID to find.</param>
|
||||
/// <returns>A game object or null.</returns>
|
||||
public GameObject? SearchById(ulong objectId);
|
||||
public GameObject? SearchById(ulong gameObjectId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the game object at the specified index of the object table.
|
||||
|
|
|
|||
|
|
@ -711,7 +711,7 @@ public static class Util
|
|||
internal static void PrintGameObject(GameObject actor, string tag, bool resolveGameData)
|
||||
{
|
||||
var actorString =
|
||||
$"{actor.Address.ToInt64():X}:{actor.ObjectId:X}[{tag}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX} R{actor.Rotation} - Target: {actor.TargetObjectId:X}\n";
|
||||
$"{actor.Address.ToInt64():X}:{actor.GameObjectId:X}[{tag}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX} R{actor.Rotation} - Target: {actor.TargetObjectId:X}\n";
|
||||
|
||||
if (actor is Npc npc)
|
||||
actorString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue