diff --git a/ScreenshotMetadata.cs b/ScreenshotMetadata.cs index 160a3f2..d8d2505 100644 --- a/ScreenshotMetadata.cs +++ b/ScreenshotMetadata.cs @@ -1,5 +1,4 @@ using System.Numerics; -using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game.Housing; @@ -100,26 +99,38 @@ public class ScreenshotMetadata { // var relevantModObjects = new List(); var relevantModObjects = new List(); var visible = plugin.ObjectTable - .Where(obj => { + .Select((obj, idx) => (obj, idx)) + .Where(tuple => { + var (obj, idx) = tuple; // pull a sneaky and populate the relevantModObjects list here if ( obj.ObjectKind is - ObjectKind.Player - or ObjectKind.Companion - or ObjectKind.BattleNpc - or ObjectKind.EventNpc - or ObjectKind.MountType - or ObjectKind.Retainer + ObjectKind.Player + or ObjectKind.Companion + or ObjectKind.BattleNpc + or ObjectKind.EventNpc + or ObjectKind.MountType + or ObjectKind.Retainer ) { - if (obj.ObjectId > ushort.MaxValue) { - Plugin.Log.Warning($"cannot pass object with id {obj.ObjectId} to Penumbra: too large"); + if (idx > ushort.MaxValue) { + Plugin.Log.Warning($"cannot pass object with idx {idx} to Penumbra: too large"); } else { - relevantModObjects.Add((ushort) obj.ObjectId); + unsafe { + var gobj = (GameObject*) obj.Address; + var draw = gobj->DrawObject; + if (draw != null && draw->IsVisible) { + var visible = plugin.GameGui.WorldToScreen(obj.Position, out _, out _); + if (visible) { + relevantModObjects.Add((ushort) idx); + } + } + } } } return obj is PlayerCharacter; }) + .Select(tuple => tuple.obj) .Cast() .Where(chara => { unsafe {