using UnityEngine; using Unheimlich.Features.DetectiveBoard.Data; using Unheimlich.Core.Interaction; using Unheimlich.Features.DetectiveBoard; using Unheimlich.Features.Items; namespace Unheimlich.Features.DetectiveBoard { /// /// Unlocks a clue when the player interacts with this object. /// Can work standalone (extends InteractableBase) or piggyback on an existing InspectableItem. /// public class ClueUnlockOnInteraction : InteractableBase { [Header("Clue Configuration")] [Tooltip("The clue to unlock when player interacts")] [SerializeField] private ClueData _clueToUnlock; [Tooltip("Only unlock once")] [SerializeField] private bool _unlockOnlyOnce = true; private bool _hasUnlocked; private InspectableItem _inspectableItem; private void Awake() { _inspectableItem = GetComponent(); } public override void Interact() { if (_unlockOnlyOnce && _hasUnlocked) { if (_inspectableItem != null) _inspectableItem.Interact(); return; } if (_clueToUnlock == null) { Debug.LogError("[ClueUnlockOnInteraction] No clue data assigned!"); if (_inspectableItem != null) _inspectableItem.Interact(); return; } if (DetectiveBoardManager.Instance != null) { DetectiveBoardManager.Instance.UnlockClue(_clueToUnlock); _hasUnlocked = true; } if (_inspectableItem != null) { _inspectableItem.Interact(); } } } }