Dialogue State¶
Whether the character is being spoken to, and whether it owes an answer. This is the lane that gives a character the one state it cannot infer from its own audio, which is Listening.
The Source¶
Implement IDialogueStateSource and assign it to the brain's DialogueStateSource.
| Member | What it returns |
|---|---|
bool IsListeningToSpeaker |
Whether someone is currently speaking to this character |
bool IsWaitingForPlayerResponse |
Whether this character has finished and is waiting on the player |
This is the interface a dialogue system implements once. It already knows who is talking to whom, and answering these two questions from that is usually a few lines. A shipped example, the simple dialogue state source under Examples, shows the whole of it as two switches a conversation flips.
Two Values, Each Its Own Lane¶
The two are overridden, released and owned separately. A cutscene can claim the listening lane without touching the waiting one, and each can be held by a different owner.
brain.SetListeningToSpeaker(this, true);
brain.SetWaitingForPlayerResponse(this, false);
| Method | Does |
|---|---|
SetListeningToSpeaker(bool) |
Claims the anonymous lane |
SetListeningToSpeaker(object owner, bool) |
Claims it as this owner |
ReleaseListeningToSpeakerOverride() |
Gives back the anonymous lane |
TryReleaseListeningToSpeakerOverride(object owner) |
Gives it back only if this owner still holds it |
ForceClearListeningToSpeakerOverride() |
Takes it back regardless |
WaitingForPlayerResponse has the same five, named the same way. ForceClearDialogueStateOverrides() clears both lanes at once.
Asking About It¶
| Member | Tells you |
|---|---|
IsListeningToSpeaker |
The resolved value, override or source |
IsWaitingForPlayerResponse |
The resolved value, override or source |
Is…OverridePresent |
Whether an override is masking the source, per value |
Is…OverrideOwner(object owner) |
Whether this owner holds it, per value |
…OverrideOwner, …OverrideOwnerKind |
Who holds it and how, per value |
Events¶
DialogueStateOverrideChanged fires when either lane's override changes, with a DialogueStateOverrideChange carrying:
| Field | Holds |
|---|---|
Member |
Which value changed: ListeningToSpeaker or WaitingForPlayerResponse |
Transition |
Which kind of change. See Sources and Overrides |
HadPreviousOverride |
Whether an override was present before |
PreviousValue |
What it was |
PreviousOwnerKind |
Who held it before |
One event serves both lanes, so check Member first.
Where It Reaches¶
Into the conversant state, which resolves to Talking, Listening or Idle and is read by the eyes and by breath. What each of those states changes is set out in Speaking and Listening.
Listening Is the Reason This Lane Exists
A character can tell it is Talking from its own audio. It cannot tell it is Listening, because nothing is playing. This lane is how it finds out, and until you wire it up a character will never resolve to Listening at all.