Hallucination system

This commit is contained in:
Ferlat Thibaud
2026-03-16 17:06:47 +01:00
parent 10faf74405
commit 0d968f75ab
44 changed files with 2860 additions and 909 deletions
@@ -53,8 +53,35 @@ namespace Unheimlich.Features.Dialogue
private float _autoCloseTimer = 0f;
private bool _isWaitingForAutoClose = false;
protected override void OnAwake()
protected override void OnAwake() { }
protected override void OnEnabled()
{
// With Scene Reload disabled, Start() doesn't run again each session.
// We recreate the focus system to clear any stale locked state (_isFocusLocked,
// _focusTimer, _currentFocusedHandler) that may have carried over.
if (_focusSystem != null)
{
_mainCamera = Camera.main;
_focusSystem = new DialogueFocusSystem(
this,
_mainCamera,
PlayerController.Instance?.CameraEffects,
_choiceLayer,
_focusRange,
_focusTime,
_raycastInterval,
_recoveryDuration,
_focusRetentionTime,
_fallbackShakeIntensity
);
_focusSystem.OnChoiceMade += (choice) => OnChoiceMade?.Invoke(choice);
// Also reset dialogue state in case we exited mid-dialogue
IsInDialogue = false;
_isWaitingForAutoClose = false;
_autoCloseTimer = 0f;
}
}
private void Start()
@@ -82,6 +109,13 @@ namespace Unheimlich.Features.Dialogue
if (!IsInDialogue)
return;
if (_activeDialogueUI == null)
{
Debug.LogError("[DialogueManager] IsInDialogue is true but _activeDialogueUI is null. Forcing dialogue end.", this);
IsInDialogue = false;
return;
}
if (!_activeDialogueUI.AreChoicesVisible())
{
if (_isWaitingForAutoClose && _currentNode != null && _currentNode.AutoCloseDelay > 0f)
@@ -142,6 +176,12 @@ namespace Unheimlich.Features.Dialogue
_activeDialogueUI = customDialogueUI;
CurrentOwner = owner;
if (_activeDialogueUI == null)
{
Debug.LogError("[DialogueManager] StartConversation called with no DialogueUI. Assign a Local Dialogue UI on the DialogueTriggerZone that triggered this conversation.", this);
return;
}
ShowCurrentNode();
}