Skip to main content

Chat System Service

Description

The main runtime controller for player-facing conversations. It manages the conversation lifecycle from open to close, navigates through nodes, handles option selection, and coordinates beat playback.

One instance lives in the scene, on the Chat System prefab that Dialogue UI Service instantiates. Unlike Headless Conversation Controller, only one player conversation can be active at a time. See Player Conversations.

Interface

Type
IChatFlowController
IRuntimeDialogueDeadEndHandler

Inherits

Type
MonoBehaviour

Properties

NameTypeDescription
CurrentNodeChatDataThe node currently being played, or null.

Inspector Fields

Serialized private fields, set on the prefab rather than through the API.

NameTypeDescription
defaultTreeChatTreeDataTree used when the agent supplies none.
activeChatTreeChatTreeDataThe tree resolved for the current conversation.
dialoguePanelViewDialoguePanelViewThe panel this service drives. Also assignable through BindPanelView.

Public Methods

NameParametersReturn TypeDescription
ApplyCurrentChatIAgentService agent, IAgentService listener = nullvoidOpens a conversation with the given agent, resolves the tree, and begins playback.
ApplyCurrentChatstring idvoidNavigates to a specific node by ID within the current conversation.
SelectOptionstring selectedOptionvoidCalled when the player selects a dialogue option.
AdvanceBeatOrDisplayOptionsN/AvoidAdvances to the next beat group, or shows options if at the last.
IsChatActiveN/AboolReturns true while a conversation is open.
GetActiveAgentN/AIAgentServiceReturns the agent the player is currently talking to, or null.
BindPanelViewDialoguePanelView panelViewvoidBinds the panel this service drives. Called during UI initialization.
CloseChatN/AvoidCloses the current conversation and cleans up all session state.
HandleRuntimeDeadEndChatData activeNode, string warningvoidDead-end handler. Logs the warning and closes the conversation cleanly.