diff --git a/Dalamud/Game/ClientState/Objects/ObjectTable.cs b/Dalamud/Game/ClientState/Objects/ObjectTable.cs index a9bf057c5..d88383c22 100644 --- a/Dalamud/Game/ClientState/Objects/ObjectTable.cs +++ b/Dalamud/Game/ClientState/Objects/ObjectTable.cs @@ -98,6 +98,23 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable return null; } + /// + public IGameObject? SearchByEntityId(uint entityId) + { + _ = this.WarnMultithreadedUsage(); + + if (entityId is 0 or 0xE0000000) + return null; + + foreach (var e in this.cachedObjectTable) + { + if (e.Update() is { } o && o.EntityId == entityId) + return o; + } + + return null; + } + /// public unsafe nint GetObjectAddress(int index) { diff --git a/Dalamud/Plugin/Services/IObjectTable.cs b/Dalamud/Plugin/Services/IObjectTable.cs index a74e6db7a..ad2c4d6dc 100644 --- a/Dalamud/Plugin/Services/IObjectTable.cs +++ b/Dalamud/Plugin/Services/IObjectTable.cs @@ -33,6 +33,13 @@ public interface IObjectTable : IEnumerable /// A game object or null. public IGameObject? SearchById(ulong gameObjectId); + /// + /// Search for a game object by the Entity ID. + /// + /// Entity ID to find. + /// A game object or null. + public IGameObject? SearchByEntityId(uint entityId); + /// /// Gets the address of the game object at the specified index of the object table. ///