Skip to content

Dialogue Flow

Dominik Morse edited this page Nov 16, 2024 · 5 revisions

How does 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.

Single-Player Scenario

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
Loading

Multi-Player Scenario

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
Loading

Clone this wiki locally