Check if sequencer commands are pending

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Check if sequencer commands are pending

Post by VoodooDetective »

I'm trying to make it so my subtitles hide if:

- they've been superseded
- the conversation is ending
- sequencer commands are still running even after a specific message fires

I have a message "DialogueDone" that fires when a character finishes speaking a line (+ a 0.8 second delay). I'd like to make it so HidePanel() happens if the sequencer is still executing after that message. I'm just trying to find the best way to do that.

Seems like I could try making HandleHidePanelInternally public, and have a custom sequencer command HidePanelConditional()@Message(DialogueDone) that checks if any sequencer commands are still running. If they are, I can hide the current subtitle, and if not do nothing.

There's probably a better way to do this, so I figured I'd ask your opinion.
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Check if sequencer commands are pending

Post by Tony Li »

What sends the message "DialogueDone"?

Technically you can check DialogueManager.conversationView.sequencer.isPlaying but it may not return what you want, since commands could be queued or active. If you're sending a message from a sequencer command -- such as:

Code: Select all

AudioWait(entrytag)->Message(DialogueDone)
Then AudioWait is technically still active at the time that it's sending the DialogueDone message, so isPlaying will be true.

There's an undocumented but supported scripting message called "OnSequencerMessage". It's sent to the Dialogue Manager GameObject with every sequencer message. I don't know if that would be any help, but you could add a script to the Dialogue Manager with an OnSequencerMessage method:

Code: Select all

void OnSequencerMessage(string message)
{
    if (message == "DialogueDone") 
    {
        DialogueManager.standardDialogueUI.conversationUIElements.defaultNPCSubtitlePanel.Close();
    }
}
I'm not exactly sure what your criteria are for pending/active, and whether you always want to hide panel(s) on DialogueDone or only sometimes. If the info above doesn't help, please drop a few more details in a reply.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Check if sequencer commands are pending

Post by VoodooDetective »

Ahh OK so a few more details. Here is our default Sequence for both NPC and PC:

Code: Select all

DialogueWait(entrytag)@Message(SubtitleOpened)->Message(VoiceComplete);
SendMessage(ActionFinished,,Voodoo Detective Dialogue Manager)@Message(VoiceComplete); 
WaitForMessage(DialogueDone);
ActionFinished() starts a coroutine that does a DialogueTime.WaitForSeconds(0.8f) seconds before calling Sequencer.Message("DialogueDone").


Because WaitForMessage() will still be running in the base case, I'd thought maybe something like this could work:

Code: Select all

            if (Sequencer.s_awakeSequencer.PendingCommandCount > 1)
            {
                Debug.Log("Closing Subtitle Panel - Extra ");
                VoodooDetectiveSubtitlePanel.CurrentSubtitlePanel.Close();
            }
Where PendingCommandCount looks like this:

Code: Select all

public int PendingCommandCount { get { return (m_activeCommands.Count + m_queuedCommands.Count); } }



Basically, I'd like to check if the Sequencer is running any commands that will last beyond DialogueDone. If so, then I'd like to close the subtitle panel rather than wait until it's superseded. The vase majority of times this happens, we're making something happen in the game that we'd like to see and the subtitle panel can end up blocking it.

I guess if we wanted to get even more clever about it, we could check to see which commands were pending, but I don't think that's strictly necessary.



Another possibility could be to create a custom sequencer message that does the 0.8f wait and then checks if PendingCommandCount > 1. Pretty much the same idea, maybe a little simpler. Maybe then instead of PendingCommandCount it could do:

Code: Select all

Sequencer.AnyOtherCommandsRunning(this)
or something, but that seems less reusable. Can you think of a better way to handle all this?
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Check if sequencer commands are pending

Post by Tony Li »

How about if I expose two properties:
  • DialogueManager.conversationView.sequencer.numActiveCommands and
  • .numQueuedCommands
WaitForMessage() will still be waiting for the message, so numActiveCommands will always be 1 or higher.

If the sum is greater than 1, you can hide the subtitle panel.

Why not do this all in DialogueWait()? Your DialogueWait() command could:
  • Play the voice
  • Maybe send a message "VoiceComplete" if you still need it
  • Wait an extra 0.8 seconds
  • Check if there are any other active or queued sequencer commands. If not, hide the subtitle panel
Then your default sequence would just be:

Code: Select all

DialogueWait(entrytag)
---

Alternatively, if you don't want to do that, but if you also don't want to maintain ActionFinished(), I think you can replace this:

Code: Select all

SendMessage(ActionFinished,,Voodoo Detective Dialogue Manager)@Message(VoiceComplete); 
WaitForMessage(DialogueDone);
with this:

Code: Select all

Delay(0.8)@Message(VoiceComplete)
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Check if sequencer commands are pending

Post by Tony Li »

This patch has Sequencer.numQueuedCommands and numActiveCommands properties:

DS_SequencerPatch_2021-10-06.unitypackage
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Check if sequencer commands are pending

Post by VoodooDetective »

I think this'll work perfectly! Thank you very much for reading all that stuff and for the patch!
I think I'll also do as you suggest and move it all to DialogueWait. The ActionFinished thing was a vestige from when we had subtitles that used the typewriter.

Thank you!!
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Check if sequencer commands are pending

Post by Tony Li »

Glad to help!
Post Reply