using UnityEngine;
using Unheimlich.Core.Audio;
using Unheimlich.Features.DetectiveBoard.Data;
namespace Unheimlich.Features.DetectiveBoard
{
///
/// Unlocks a clue when a specific AudioSource plays, finishes, or reaches a timestamp.
/// Call OnAudioPlay() from whatever drives the AudioSource to start monitoring.
///
public class ClueUnlockOnAudio : AudioTriggerBase
{
[Header("Clue Configuration")]
[Tooltip("The clue to unlock")]
[SerializeField] private ClueData _clueToUnlock;
protected override void Execute()
{
if (_clueToUnlock == null)
{
Debug.LogError("[ClueUnlockOnAudio] No ClueData assigned!", this);
return;
}
if (DetectiveBoardManager.Instance == null)
{
Debug.LogError("[ClueUnlockOnAudio] DetectiveBoardManager not found!", this);
return;
}
DetectiveBoardManager.Instance.UnlockClue(_clueToUnlock);
if (_debugMode)
Debug.Log($"[ClueUnlockOnAudio] Unlocked clue '{_clueToUnlock.Title}' on '{_fireCondition}'.", this);
}
/// Resets the unlock state so the clue can be unlocked again.
public void ResetUnlock() => ResetFired();
}
}