Skip to content

Dialogue

namespace Griff.Scenes;
public sealed class Dialogue : Component

Lines of talk shown one after another in a dialogue box, with choices that branch it, flags that remember what was said, and no code. Interact (E, Enter, the gamepad’s Y) finishes the line being typed, then moves on. Rows starting with “>” are choices offered under the line before them, picked with the arrow keys, D-pad, number keys or mouse and Interact, and they can go to other parts of the lines; rows can set flags and be said only when a flag is set (see Lines). A line starting with a Speaker’s name (“Guide: Hello!”) is said by them, and the rest by the Speaker on this entity, if it has one: a DialogueBox shows their name and portrait. The Box is shown while talking and hidden otherwise; put a Typewriter next to its text to type the lines out. Needs a collider, usually a trigger, unless it starts as the scene starts. Where it’s got to is saved with the scene, so a rewind goes back into the middle of a talk.

This is a component: its saved properties are on its component page.

public string? Box { get; set; }

The name of the dialogue box entity; its Text (or the first one inside it) shows the lines, and its DialogueBox, if it has one, who’s saying them.

public IReadOnlyList<string> Choices { get; }

The choices offered under the line showing, empty when there are none.

public bool CutShort { get; }

True when it was stopped before its end (by its Stop action or a script’s Game.EndDialogue) rather than said to the end: read it in a Finished handler to tell a skipped cutscene from one watched through. False again as it starts.

public string? Expression { get; }

The expression the line showing is said with, from its speaker’s name (“Ava (happy): …” says it happy), or null: a visual novel’s stage shows the character that way.

public bool IsDone { get; set; }

True once it has been said all the way through (or stopped: see CutShort).

public bool IsTalking { get; set; }

True while it’s being said. Saved with the scene (with Line), so a rewind or a saved game goes back into the talk; set it in the Inspector to start the game partway through one.

public string? Layers { get; set; }

The collision layers that can start it, e.g. “Player”. Empty lets anything with a Body.

public int Line { get; set; }

The row showing, from 0, while talking.

public IReadOnlyList<string> Lines { get; set; }

What’s said, one line per row. A row starting with “>” is a choice offered under the line before it, and one ending in “-> Name” goes to the row “# Name” when it’s picked (“> Buy a sword -> Shop”); a choice without one goes on after the choices. “# Name” starts a part that’s only reached that way: the lines before it end there. A row “-> Name” goes there by itself, and “-> End” ends. A row can start with tags in square brackets: “[if Flag]” or “[if not Flag]” says it (offers the choice, follows the go-to) only when the flag is set or isn’t; “[set Flag]” and “[clear Flag]” set and clear one, and “[send Message]” sends a message, when the line is said or the choice picked. A row of tags alone just does them. Flags are kept in the game’s save data, so they’re still set next time. “Name: …” is said by the Speaker called Name, and “Name (happy): …” with that expression (see Expression). Modules add tags of their own: a visual novel stage’s “[show Ava left happy]”, “[hide Ava]”, “[move Ava right]” and “[background Park fade]”. Start a row with “\” to say it as it is, “>”, “#”, “[” and all.

public string? Message { get; set; }

A message sent with Game.Send when the last line is done, e.g. “TalkedToKing”.

public bool NeedsNoCollider { get; }

True for one that needs no collider: it starts with the scene, or something else on its entity starts it (an adventure’s hotspot that talks when it’s used).

public bool Once { get; set; }

Only ever say it once, e.g. for a cutscene.

public bool PauseGame { get; set; }

Stop game time while talking, so nothing moves (or gets hurt) until it’s over.

public string? Pauses { get; set; }

What it stops while it’s being said: empty stops the whole game; an entity’s name stops only it and everything inside it, as a PauseGroup does (the enemies, a minigame), while the rest runs on.

public int Picked { get; }

The choice the arrow keys or mouse are on, from 0, while there are Choices; Interact picks it.

public string? Prompt { get; set; }

The name of an entity to show only while it can be started, e.g. a “Press E” hint above someone. It’s hidden the rest of the time.

public string? Said { get; }

The line showing as it’s said, without the speaker’s name it starts with; null while only choices show.

public Speaker? Speaker { get; }

Who is saying the line showing, or null when no Speaker is (a sign, say).

public DialogueStart Start { get; set; }

Whether the talk starts when the player presses Interact by it, or as soon as they touch it.

public bool StartsWithScene { get; }

True for one that starts by itself as the scene starts, which needs no collider.

public bool AcceptsLayer(string? layer)

True if something on collision layer layer can start it.

public static IReadOnlyDictionary<string, Type> ClaimTags(IEnumerable<Type> types)

Which component claims each tag word (DialogueTagsAttribute) among types.

public IReadOnlyList<string> GoesNowhere()

The parts its choices and go-tos go to that none of its lines starts (End always ends), each once.

public static bool IsTagWord(string word)

True if word starts one of a module’s own dialogue tags (see DialogueTagsAttribute), e.g. “show” for a visual novel’s “[show Ava left]”.

public IReadOnlyList<string> PartNames()

The parts its lines start (“# Shop”), by name, in order.

public Dialogue.DialogueRow Row(int row)

Reads row row of Lines.

public static ValueTuple<string, string, string> SplitSpeaker(string text)

Splits “Name: what they say” into the name and what’s said, when the line starts that way, and “Name (happy): …” into the name, the expression and what’s said. The name is only a speaker’s if a Speaker is called it (the game checks); otherwise it’s all said.

public event Action<int>? Chosen

Raised when a choice is picked, with its number in Choices (before the talk moves on).

public event Action? Finished

Raised when the last line is done, or it’s stopped partway (CutShort says which).

public event Action<int>? LineShown

Raised as each line is shown, with its number.