# Dialogue Graph

## ⚙️ DialogueGraph Class

A graph that contains nodes and connections.

> Namespace: `Esper.FeelSpeak.Graph`\
> Inherits from: `FeelSpeakObject`\
> Type: `class`

***

### 📦 Fields

| Access   | Field                       | Type                 | Description                                                                           |
| -------- | --------------------------- | -------------------- | ------------------------------------------------------------------------------------- |
| `public` | `graphName`                 | `string`             | The searchable name of the graph.                                                     |
| `public` | `startingNodeId`            | `int`                | The ID of the starting node. This is equal to -1 if a starting node has not been set. |
| `public` | `dialogueNodes`             | `List<DialogueNode>` | A list of dialogue nodes.                                                             |
| `public` | `choiceNodes`               | `List<ChoiceNode>`   | A list of choice nodes.                                                               |
| `public` | `delayNodes`                | `List<DelayNode>`    | A list of delay nodes.                                                                |
| `public` | `soundNodes`                | `List<SoundNode>`    | A list of sound nodes.                                                                |
| `public` | `connections`               | `List<Connection>`   | A list of all connections.                                                            |
| `public` | `callOnceOnDialogueStarted` | `UnityEvent`         | A callback for when any dialogue graph begins. All events are cleared after invoke.   |
| `public` | `callOnceOnDialogueEnded`   | `UnityEvent`         | A callback for when any dialogue graph ends. All events are cleared after invoke.     |

***

### 🔍 Static Properties

| Access   | Property        | Type     | Description                                                           |
| -------- | --------------- | -------- | --------------------------------------------------------------------- |
| `public` | `resourcesPath` | `string` | The path to all generated objects of this type relative to resources. |

***

### 🔍 Properties

| Access   | Property         | Type             | Description          |
| -------- | ---------------- | ---------------- | -------------------- |
| `public` | `DatabaseRecord` | `DialogueRecord` | The database record. |

***

### 🧰 Methods

| Access      | Method                         | Returns         | Description                                                       |
| ----------- | ------------------------------ | --------------- | ----------------------------------------------------------------- |
| `public`    | `AddNode(Node)`                | `void`          | Adds a node to the appropriate collection based on its type.      |
| `public`    | `RemoveNode(Node)`             | `void`          | Removes a node from the appropriate collection based on its type. |
| `public`    | `CreateCopy()`                 | `DialogueGraph` | Creates a copy of this object.                                    |
| `public`    | `CopyData(DialogueGraph)`      | `void`          | Copies all data of another dialogue, excluding ID.                |
| `public`    | `Create(DialogueGroup)`        | `DialogueGraph` | Creates a new instance of a DialogueGraph (editor only).          |
| `public`    | `UpdateAssetName()`            | `void`          | Updates the name of the asset (editor only).                      |
| `public`    | `Save()`                       | `void`          | Saves the dialogue graph and updates database record.             |
| `protected` | `GetID<T>(string)`             | `int`           | Returns an unused ID for this type.                               |
| `public`    | `GetAvailableNodeID()`         | `int`           | Returns an unused node ID.                                        |
| `public`    | `Trigger()`                    | `void`          | Triggers this dialogue.                                           |
| `public`    | `ValidateConnectionsInNodes()` | `void`          | Applies all connections to nodes.                                 |
| `public`    | `PopulateConnections(Node)`    | `void`          | Repopulates the connection lists of a node.                       |

## Getting a Dialogue Graph

You can get a `DialogueGraph` at runtime with their ID or name with the `FeelSpeak.GetDialogueGraph` method.

```csharp
var myDialogueGraph = FeelSpeak.GetDialogueGraph("dialogue name");
```
