From c7961eb444eff282711d0efc749bf981316b419d Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 8 Aug 2024 14:48:33 +0200 Subject: [PATCH] Partially revert interaction IsTargetable changes and make GatheringPoint a special case --- Questionable/Controller/Steps/Interactions/Interact.cs | 4 ++-- Questionable/Functions/GameFunctions.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Questionable/Controller/Steps/Interactions/Interact.cs b/Questionable/Controller/Steps/Interactions/Interact.cs index 85e56c444..cb2b3d6c4 100644 --- a/Questionable/Controller/Steps/Interactions/Interact.cs +++ b/Questionable/Controller/Steps/Interactions/Interact.cs @@ -66,7 +66,7 @@ internal static class Interact public bool Start() { - IGameObject? gameObject = gameFunctions.FindObjectByDataId(DataId, targetable: true); + IGameObject? gameObject = gameFunctions.FindObjectByDataId(DataId); if (gameObject == null) { logger.LogWarning("No game object with dataId {DataId}", DataId); @@ -113,7 +113,7 @@ internal static class Interact if (!_interacted) { - IGameObject? gameObject = gameFunctions.FindObjectByDataId(DataId, targetable: true); + IGameObject? gameObject = gameFunctions.FindObjectByDataId(DataId); if (gameObject == null || !IsTargetable(gameObject) || !HasAnyMarker(gameObject)) return ETaskResult.StillRunning; diff --git a/Questionable/Functions/GameFunctions.cs b/Questionable/Functions/GameFunctions.cs index 73f2a1954..d52dd4697 100644 --- a/Questionable/Functions/GameFunctions.cs +++ b/Questionable/Functions/GameFunctions.cs @@ -157,17 +157,19 @@ internal sealed unsafe class GameFunctions playerState->IsAetherCurrentUnlocked(aetherCurrentId); } - public IGameObject? FindObjectByDataId(uint dataId, ObjectKind? kind = null, bool targetable = false) + public IGameObject? FindObjectByDataId(uint dataId, ObjectKind? kind = null) { foreach (var gameObject in _objectTable) { - if (targetable && !gameObject.IsTargetable) - continue; - if (gameObject.ObjectKind is ObjectKind.Player or ObjectKind.Companion or ObjectKind.MountType or ObjectKind.Retainer or ObjectKind.Housing) continue; + // multiple objects in the object table can share the same data id for gathering points; only one of those + // (at most) is visible + if (gameObject is { ObjectKind: ObjectKind.GatheringPoint, IsTargetable: false }) + continue; + if (gameObject.DataId == dataId && (kind == null || kind.Value == gameObject.ObjectKind)) { return gameObject;