From 72de408c072f40a9d281a3e9f9059eb6a79078e0 Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Mon, 23 Nov 2026 02:03:23 +0000 Subject: [PATCH] fix: grabbing a bed again during its sleep dialog no longer breaks every later dialog (NPCs turned to the hero but said nothing) Co-Authored-By: Claude Opus 5.5 --- .../Scripts/Services/Player/DialogService.cs | 19 +++++++++++++++++++ .../Services/Vobs/MobInteractionService.cs | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/Assets/Gothic-Core/Scripts/Services/Player/DialogService.cs b/Assets/Gothic-Core/Scripts/Services/Player/DialogService.cs index e671041c4..05796abfd 100644 --- a/Assets/Gothic-Core/Scripts/Services/Player/DialogService.cs +++ b/Assets/Gothic-Core/Scripts/Services/Player/DialogService.cs @@ -43,6 +43,13 @@ public class DialogService private const float _heroQueueActionTimeout = 30f; private bool _isHeroQueueRunning; + /// + /// A dialog is open or the hero's queue is about to open one (a mob's _S1 queued AI_ProcessInfos). Like the + /// engine, no mob is used then: a second grab at a bed started a new mob dialog that destroyed the open one's + /// anchor - with the dialog box on it - and every dialog after failed (Bartok turned to the hero, said nothing). + /// + public bool IsBusy => _gameStateService.Dialogs.IsInDialog || _isHeroQueueRunning; + private readonly DialogHeroHoldDomain _heroHoldDomain = new DialogHeroHoldDomain().Inject(); /// @@ -61,6 +68,8 @@ public void Init() /// private void StopDialogOnUnloadGame() { + // The hero queue's coroutine stops with the scene without its finally - the flag would block mobs (IsBusy). + _isHeroQueueRunning = false; var dialogNpc = _gameStateService.Dialogs.CurrentDialogNpc; if (!_gameStateService.Dialogs.IsInDialog || dialogNpc == null) return; @@ -433,6 +442,16 @@ public void ExtAiStopProcessInfos(NpcInstance npc) /// public void PrepareMobDialog(GameObject anchor) { + // The open dialog's box hangs on the old anchor - end it first (moves the box away), or it's destroyed + // with the anchor and every later dialog fails. MobInteractionService doesn't get here while busy. + var openDialogNpc = _gameStateService.Dialogs.CurrentDialogNpc; + if (_gameStateService.Dialogs.IsInDialog && openDialogNpc != null) + { + Logger.LogWarning("[MobDialog] A new mob dialog while one is open - closing the open one.", + LogCat.Dialog); + StopDialog(openDialogNpc); + } + if (MobDialogAnchor != null) Object.Destroy(MobDialogAnchor); diff --git a/Assets/Gothic-Core/Scripts/Services/Vobs/MobInteractionService.cs b/Assets/Gothic-Core/Scripts/Services/Vobs/MobInteractionService.cs index 94356d941..9553fb6b0 100644 --- a/Assets/Gothic-Core/Scripts/Services/Vobs/MobInteractionService.cs +++ b/Assets/Gothic-Core/Scripts/Services/Vobs/MobInteractionService.cs @@ -62,6 +62,13 @@ public void HandleMobGrab(VobLoader loader, Func createDialogAnchor, if (loader.Container.Vob is not IInteractiveObject mob || vm == null) return; + // While talking (or a mob dialog is about to open) no mob is used - VR grabs fire repeatedly. + if (_dialogService.IsBusy) + { + Logger.Log($"[MobInteractionService] {loader.gameObject.name} ignored - a dialog is open", LogCat.Vob); + return; + } + // Touching a fireplace/torch lights it or puts it out until its mob routine switches (FireService). if (mob is IFire && _fireService.TryToggle(loader.gameObject)) return;