-
-
Notifications
You must be signed in to change notification settings - Fork 32
Dialogue Flow
In this chapter, I would like to describe how the dialogue works in high-level abstract detail. I will use two scenarios: the Single-Player and Multi-Player situations.
Both scenarios use the same code and functions; the only differentiating factor is the server overhead. So diagram flows will showcase both scenarios we have established, however, the description of each step will be generic to fit both situations. With this information provided, let's take a look at the actual Dialogue Flow.
Dialogues can be started using the RequestStartDialogue function, which is exposed to Blueprints using the MounteaDialogueManagerStatics library. This is the very beginning of the dialogue flow, where the Dialogue Manager is asked whether dialogue can even start. Multiple validations are processed for each step of the request. This process goes through the whole function to gather as much information as possible so the user is informed about all failed reasons at once.
Some validation steps vary between Dialogue Manager types, but those are technical details which will be explained in different chapters.
After all validations are passed, the evaluation returns whether any errors occurred. If so, the OnDialogueFailed event is triggered with gathered information from all failed steps. Otherwise OnDialogueStartRequested is triggered, marking a successful validation. No matter the Request result Manager's state is updated.
The SetManagerState function is responsible for updating the state of the dialogue manager and triggering necessary updates when the state changes. The state transition logic ensures that updates only occur when the new state differs from the current state. If the transition is valid, appropriate actions are performed based on the new state.
- New State Validation: If the new state matches the current state, the update is aborted, and no further action is taken.
- State Update: The state change is processed and validated. For server-authoritative systems, the state is updated directly and processed further.
This function processes the state update once it has been applied, ensuring the necessary actions are performed for the new state.
- Context Handling: For the active state, if the dialogue context is not ready, the process is deferred until it becomes valid.
- State-Specific Actions:
-
- Disabled/Enabled: Ensures the dialogue is closed.
-
- Active: Initiates the actual dialogue flow.
sequenceDiagram
participant Player
participant Manager
participant Context
participant UI
Note over Player,UI: Single Player Flow
Player->>Manager: RequestStartDialogue
activate Manager
Manager->>Manager: ValidateRequest
Manager->>Context: CreateContext
Manager->>Manager: SetManagerState(Active)
Manager->>Manager: StartParticipants
Manager->>UI: CreateDialogueUI
Manager->>Manager: PrepareNode
loop Dialogue Processing
Manager->>Manager: ProcessNode
Manager->>Manager: ProcessDialogueRow
Manager->>UI: UpdateDialogueUI
alt Row Complete
Manager->>Manager: DialogueRowProcessed
Manager->>Manager: NodeProcessed
else Node Complete
Manager->>Manager: SelectNode/CloseDialogue
end
end
Manager->>Manager: CleanupDialogue
Manager->>UI: CloseDialogueUI
deactivate Manager
sequenceDiagram
participant Client
participant Server
participant RemoteClients
participant Context
participant UI
Note over Client,UI: Multiplayer Flow
Client->>Client: RequestStartDialogue
Client->>Server: RequestStartDialogue_Server
activate Server
Server->>Context: CreateContext
Server->>Server: SetManagerState(Active)
Server->>Client: Rep_ManagerState
Server->>RemoteClients: Rep_ManagerState
par Client UI Updates
Client->>Client: StartParticipants
Client->>UI: CreateDialogueUI
Client->>UI: UpdateDialogueUI
and Remote Clients UI
RemoteClients->>RemoteClients: StartParticipants
RemoteClients->>UI: UpdateWorldDialogueUI
end
loop Dialogue Processing
alt Client Input
Client->>Client: SelectNode
Client->>Server: SelectNode_Server
Server->>Context: UpdateContext
Server->>Client: Rep_Context
Server->>RemoteClients: Rep_Context
else Auto Progress
Client->>Client: ProcessNode
Client->>Client: ProcessDialogueRow
Client->>Server: UpdateContext_Server
Server->>Context: UpdateContext
Server->>RemoteClients: Rep_Context
end
par UI Updates
Client->>UI: UpdateDialogueUI
RemoteClients->>UI: UpdateWorldDialogueUI
end
end
Client->>Client: CleanupDialogue
Client->>Server: CleanupDialogue_Server
Server->>Server: CleanupDialogue
Server->>RemoteClients: Rep_ManagerState
Client->>UI: CloseDialogueUI
deactivate Server
