Files
Ipseity-Demo/Assets/Unheimlich_POC/Scripts/Features/DetectiveBoard/Runtime/ClueUnlockOnAudio.cs
T

41 lines
1.3 KiB
C#

using UnityEngine;
using Unheimlich.Core.Audio;
using Unheimlich.Features.DetectiveBoard.Data;
namespace Unheimlich.Features.DetectiveBoard
{
/// <summary>
/// Unlocks a clue when a specific AudioSource plays, finishes, or reaches a timestamp.
/// Call OnAudioPlay() from whatever drives the AudioSource to start monitoring.
/// </summary>
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);
}
/// <summary>Resets the unlock state so the clue can be unlocked again.</summary>
public void ResetUnlock() => ResetFired();
}
}