fix: check other objects correctly

This commit is contained in:
Anna 2024-02-18 15:51:23 -05:00
parent 42e4bcd4dd
commit 9ffb0e7854
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 22 additions and 11 deletions

View File

@ -1,5 +1,4 @@
using System.Numerics; using System.Numerics;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Utility; using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game.Housing; using FFXIVClientStructs.FFXIV.Client.Game.Housing;
@ -100,26 +99,38 @@ public class ScreenshotMetadata {
// var relevantModObjects = new List<Dalamud.Game.ClientState.Objects.Types.GameObject>(); // var relevantModObjects = new List<Dalamud.Game.ClientState.Objects.Types.GameObject>();
var relevantModObjects = new List<ushort>(); var relevantModObjects = new List<ushort>();
var visible = plugin.ObjectTable 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 // pull a sneaky and populate the relevantModObjects list here
if ( if (
obj.ObjectKind is obj.ObjectKind is
ObjectKind.Player ObjectKind.Player
or ObjectKind.Companion or ObjectKind.Companion
or ObjectKind.BattleNpc or ObjectKind.BattleNpc
or ObjectKind.EventNpc or ObjectKind.EventNpc
or ObjectKind.MountType or ObjectKind.MountType
or ObjectKind.Retainer or ObjectKind.Retainer
) { ) {
if (obj.ObjectId > ushort.MaxValue) { if (idx > ushort.MaxValue) {
Plugin.Log.Warning($"cannot pass object with id {obj.ObjectId} to Penumbra: too large"); Plugin.Log.Warning($"cannot pass object with idx {idx} to Penumbra: too large");
} else { } 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; return obj is PlayerCharacter;
}) })
.Select(tuple => tuple.obj)
.Cast<PlayerCharacter>() .Cast<PlayerCharacter>()
.Where(chara => { .Where(chara => {
unsafe { unsafe {