Files
Ipseity-Demo/Assets/Unheimlich_POC/Scripts/Handlers/DetectiveBoard/ClueUnlockOnInteraction.cs
T
2026-02-10 03:00:41 +01:00

44 lines
1.4 KiB
C#

using UnityEngine;
using Unheimlich.Data.DetectiveBoard;
using Unheimlich.Interactions.Core;
using Unheimlich.Managers;
namespace Unheimlich.Handlers.DetectiveBoard
{
/// <summary>
/// Unlocks a clue when the player interacts with this object.
/// Extends InteractableBase to integrate with the existing interaction system.
/// </summary>
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;
public override void Interact(GameObject interactor)
{
if (_unlockOnlyOnce && _hasUnlocked)
return;
if (_clueToUnlock == null)
{
Debug.LogError("[ClueUnlockOnInteraction] No clue data assigned!");
return;
}
if (DetectiveBoardManager.Instance != null)
{
DetectiveBoardManager.Instance.UnlockClue(_clueToUnlock);
_hasUnlocked = true;
Debug.Log($"[ClueUnlockOnInteraction] Unlocked clue: {_clueToUnlock.Title} via interaction");
}
}
}
}