Agent Chat Service
Description
The per-character dialogue agent. AgentChatService is the MonoBehaviour you place on an NPC; it resolves the agent's chat tree, owns the agent's mood and non-verbal eventing, and either owns or delegates the agent's identity, blackboard, and pause state.
For setup and authoring guidance, see Dialogue Agents.
Interface
| Type |
|---|
| IListenerAwareDialogueAgentService |
| IBlackboardValueOwner |
IListenerAwareDialogueAgentService extends IDialogueAgentService, which extends the shared IAgentService.
Inherits
| Type |
|---|
| MonoBehaviour |
Inspector Fields
| Name | Type | Description |
|---|---|---|
| chatTree | ChatTreeData | Tree used for player conversations. |
| headlessChatTree | ChatTreeData | Tree used for agent-to-agent conversations. |
| localTreeSelectionOverrides | DialogueTreeSelectionRule[] | Per-agent conditional tree rules, checked first. |
| sharedTreeSelection | DialogueTreeSelectionRepository | Shared rule set, checked after the local overrides. |
| portrait | Sprite | Portrait shown while this agent speaks. |
| moodRepository | MoodRepository | The moods available to this agent. |
| blackboardValueTemplates | BlackboardValueTemplate[] | Shared blackboard seed values, applied first. |
| blackboardValues | BlackboardValue[] | Agent-specific blackboard seed values, applied second. |
Public Methods
| Name | Parameters | Return Type | Description |
|---|---|---|---|
| Initialize | N/A | void | Prepares the agent for use. Called automatically on start; safe to call again. |
| FetchChatTree | N/A | ChatTreeData | Returns the plain chat tree field. |
| FetchChatTree | DialogueParticipants participants | ChatTreeData | Runs tree selection: local overrides, then shared rules, then repository fallback, then the plain field. |
| FetchHeadlessChatTree | N/A | ChatTreeData | Returns the headless tree field. Not rule-selected. |
| GetLocalTreeSelectionOverrides | N/A | IReadOnlyList<DialogueTreeSelectionRule> | Every local rule, including ones that did not win selection. |
| GetSharedTreeSelection | N/A | DialogueTreeSelectionRepository | The shared rule repository, if one is assigned. |
| GetMoodService | N/A | IDialogueMoodService | This agent's mood service, initializing first if needed. |
| GetNonVerbalEventingService | N/A | NonVerbalEventingService | This agent's non-verbal eventing, initializing first if needed. |
| GetPauseService | N/A | IPauseService | The shared agent's pause service, or its own. |
| GetBlackboardService | N/A | IBlackboardService | The shared agent's blackboard, or its own. |
| GetBlackboardValues | N/A | BlackboardValue[] | The agent-specific seed values. |
| GetBlackboardValueTemplates | N/A | BlackboardValueTemplate[] | The template assets assigned to this agent. |
| SetBlackboardValues | BlackboardValue[] values | void | Replaces the agent-specific values and re-applies them. |
| SetBlackboardValueTemplates | BlackboardValueTemplate[] templates | void | Replaces the templates and re-applies them. |
| GetResolvedBlackboardValues | N/A | BlackboardValue[] | Template values followed by agent values, in application order. |
| GetPortrait | N/A | Sprite | The agent's portrait. |
| GetID | N/A | string | The shared agent's ID, or a GUID generated on first use. |
| GetDisplayName | N/A | string | The shared agent's display name, or null when standalone. |
IDialogueAgentService
The interface the conversation runtime actually depends on. Implement it to supply a dialogue agent that is not an AgentChatService.
| Member | Return Type |
|---|---|
| FetchChatTree() | ChatTreeData |
| FetchHeadlessChatTree() | ChatTreeData |
| GetMoodService() | IDialogueMoodService |
| GetNonVerbalEventingService() | NonVerbalEventingService |
| GetPortrait() | Sprite |
Plus the shared IAgentService members: GetPauseService(), GetBlackboardService(), GetID(), GetDisplayName().
IListenerAwareDialogueAgentService
Adds the one method that lets tree choice depend on who is listening.
| Member | Return Type |
|---|---|
| FetchChatTree(DialogueParticipants participants) | ChatTreeData |
The runtime checks for this interface and falls back to FetchChatTree() when an agent does not implement it.
IDialogueTreeSelector
Decides which rule wins. Register an implementation to replace the default.
| Member | Return Type |
|---|---|
| SelectTree(IReadOnlyList<DialogueTreeSelectionRule> rules, DialogueParticipants participants) | ChatTreeData |
RequirementGatedDialogueTreeSelector is the built-in default: first matching rule wins, a rule with no tree is skipped, and a rule with no requirement collection always matches.
DialogueAgentResolver
Static helper used to find the agent behind a GameObject.
| Name | Parameters | Return Type | Description |
|---|---|---|---|
| ResolveSharedAgent | GameObject target | IAgentService | Returns a non-dialogue IAgentService on the object if there is one, otherwise a dialogue agent. |
| ResolveSharedAgentInParents | Transform target | IAgentService | Walks up the hierarchy applying the same rule. |
When a CivilAI agent and an AgentChatService share a GameObject, the CivilAI agent is returned -- it is the identity for that character.