Fix: cleanup and minor perf improvements

This commit is contained in:
Ferlat Thibaud
2026-03-25 01:28:18 +01:00
parent 9fd251f6e9
commit e69bdb93f8
21 changed files with 130 additions and 136 deletions
@@ -63,7 +63,7 @@ namespace Unheimlich.Features.Dialogue
/// </summary>
public void Update()
{
if (!_manager.IsInDialogue || !_manager.CurrentDialogueUI.AreChoicesVisible())
if (!_manager.IsDialogueActive || !_manager.CurrentDialogueUI.AreChoicesVisible())
return;
_raycastTimer += Time.deltaTime;
@@ -16,7 +16,7 @@ namespace Unheimlich.Features.Dialogue
{
[Header("State")]
public bool IsInDialogue = false;
[SerializeField] private bool IsInDialogue = false;
[Header("Focus Settings")]
[SerializeField] private LayerMask _choiceLayer;
@@ -65,19 +65,7 @@ namespace Unheimlich.Features.Dialogue
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);
InitFocusSystem();
// Also reset dialogue state in case we exited mid-dialogue
IsInDialogue = false;
@@ -89,7 +77,15 @@ namespace Unheimlich.Features.Dialogue
private void Start()
{
_mainCamera = Camera.main;
InitFocusSystem();
}
/// <summary>
/// Creates or recreates the DialogueFocusSystem with the current inspector settings.
/// Called from Start and OnEnabled (domain-reload-less re-entry).
/// </summary>
private void InitFocusSystem()
{
_focusSystem = new DialogueFocusSystem(
this,
_mainCamera,