Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Assets/Gothic-Core/Scripts/Services/Player/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public class DialogService
private const float _heroQueueActionTimeout = 30f;
private bool _isHeroQueueRunning;

/// <summary>
/// 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).
/// </summary>
public bool IsBusy => _gameStateService.Dialogs.IsInDialog || _isHeroQueueRunning;

private readonly DialogHeroHoldDomain _heroHoldDomain = new DialogHeroHoldDomain().Inject();

/// <summary>
Expand All @@ -61,6 +68,8 @@ public void Init()
/// </summary>
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;
Expand Down Expand Up @@ -433,6 +442,16 @@ public void ExtAiStopProcessInfos(NpcInstance npc)
/// </summary>
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public void HandleMobGrab(VobLoader loader, Func<GameObject> 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;
Expand Down