using UnityEngine; using Unheimlich.Features.Dialogue.Data; using Unheimlich.Features.Dialogue; using Unheimlich.Features.Dialogue.UI; namespace Unheimlich.Features.Dialogue { public class DialogueStateHandler { public bool IsCompleted { get; private set; } public bool HasPausedDialogue => _pausedConversation != null && _pausedNode != null; private DialogueConversation _pausedConversation; private DialogueNode _pausedNode; private Transform _pausedChoiceAnchor; private DialogueAnimationSettings _pausedAnimationSettings; private DialogueUI _pausedDialogueUI; private object _owner; public DialogueStateHandler(object owner) { _owner = owner; } public void PauseDialogue() { if (DialogueManager.Instance == null || !DialogueManager.Instance.IsDialogueActive) return; DialogueManager dialogueManager = DialogueManager.Instance; _pausedConversation = dialogueManager.CurrentConversation; _pausedNode = dialogueManager.CurrentNode; _pausedChoiceAnchor = dialogueManager.CurrentChoiceAnchor; _pausedAnimationSettings = dialogueManager.CurrentAnimationSettings; _pausedDialogueUI = dialogueManager.CurrentDialogueUI; DialogueManager.Instance.EndDialogue(); } public void ResumeDialogue() { if (!HasPausedDialogue || DialogueManager.Instance == null) return; DialogueManager.Instance.StartConversation( _pausedConversation, _pausedChoiceAnchor, _pausedAnimationSettings, _pausedDialogueUI, _owner ); ClearPausedDialogue(); } public void MarkAsCompleted() { IsCompleted = true; ClearPausedDialogue(); } public void AllowRetrigger() { IsCompleted = false; } public void Reset() { IsCompleted = false; ClearPausedDialogue(); } private void ClearPausedDialogue() { _pausedConversation = null; _pausedNode = null; _pausedChoiceAnchor = null; _pausedAnimationSettings = null; _pausedDialogueUI = null; } } }