# Dialogue Manager

## Description

**Dialogue Manager** is a controller class responsible for managing and executing an active dialogue branch.\
It serves as an external interface between the dialogue system and the rest of the game logic, providing control over the flow of the conversation and interaction with game events.

The **Dialogue Manager** inherits from **UActorComponent** and can be added to any **AActor** by the developer at the desired point in the game.

`UDBS_DialogueManager` is the base class, but it can be inherited and extended to include any additional functionality required by the developer.

{% hint style="warning" %}
Page currently being updated.
{% endhint %}

## Functions

### CreateDialogue

{% code overflow="wrap" %}

```
UDBS_DialogueBranch* UDBS_DialogueManager::CreateDialogue(TSubclassOf<UDBS_DialogueBranch> Class, UObject* Outer, bool bBegin, FName EntryNameId)
```

{% endcode %}

{% columns %}
{% column %}
This function created new Dialogue Branch and optionally starts it.

Arguments:

* `Class`  class of Dialogue Branch.
* `Outer` Object Outer of created dialogue object. The dialogue object will be destroyed if Outer is destroyed! If this argument is left empty, Outer will be the dialogue manager.&#x20;
* `bBegin` Starts the dialogue immediately after the dialogue branch is initialized.
* `EntryNameId` the name of the Entry phase from which the dialogue branch should be started. If not specified, the dialogue will start from the Root phase.
* `Return` Created Dialogue Branch
  {% endcolumn %}

{% column %}

<figure><img src="/files/lkZUXoWU26O3W9RjdN9x" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### BeginDialogue

```
bool UDBS_DialogueManager::BeginDialogue(FName EntryNameId)
```

{% columns %}
{% column %}
Force run from root of LAST created dialogue in this manager.

Begins a Dialogue Branch if it is not already running or force restart if Dialogue Branch already running.

If Root node or next phase is not found, then the function starts the procedure for completing the Dialogue Branch.

Arguments:

* `EntryNameId` the name of the Entry phase from which the dialogue branch should be started. If not specified, the dialogue will start from the Root phase.
* `Return` returns the success of the dialogue launch
  {% endcolumn %}

{% column %}

<figure><img src="/files/pAswCa7TcW41JFWmpAbK" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### SetDialogue

{% code overflow="wrap" %}

```
bool UDBS_DialogueManager::SetDialogue(UDBS_DialogueBranch* InDialogue, bool bBegin, FName EntryNameId)
```

{% endcode %}

{% columns %}
{% column %}
Sets the dialogue branch in the current dialogue and can optionally start it.

Arguments:

* `Dialogue` Reference to the dialogue thread that must be selected
* `bBegin` Starts the dialogue immediately after the dialogue branch is initialized.
* `EntryNameId` the name of the Entry phase from which the dialogue branch should be started. If not specified, the dialogue will start from the Root phase.
* `Return` Returns the success of the dialogue branch installation. If the “Begin” parameter is true, it returns the success of the dialogue launch.
  {% endcolumn %}

{% column %}

<figure><img src="/files/skVF5jOeRESajwU6PtvO" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### RunNextPhase

```
bool UDBS_DialogueManager::RunNextPhase()
```

{% columns %}
{% column width="50%" %}
Move to the next step of the dialogue.

Begins a Dialogue Branch if it is not already running.

If Dialogue Branch is already started, this function searches for and starts the next allowed phase of the dialogue.

If Dialogue manager has created Dialogue Branch but not started it, then this function try startDialogueBranch from Root node without ForceRestart parameter.

If the next phase is not found, then the function starts the procedure for completing the Dialogue Branch.

Arguments:

* `Return` Started Phase Data.

{% endcolumn %}

{% column width="50%" %}

<figure><img src="/files/bqAEdPNI1OaesQSxP4jU" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### RunAnswerLine

```
UDBS_Data* UDBS_DialogueManager::RunAnswerLine(const int32 AnswerId)
```

{% columns %}
{% column %}
Run next phase of Dialogue Branch from Root node.

If Dialogue Branch is not running, then this function does nothing.

If Dialogue Branch is running, then this function tries to find next phase and run it.

If next phase is not found, then this function starts the procedure for completing the Dialogue Branch.

Arguments:

* `AnswerId` Index of answer options collected from those available in AnswerHub
* `Return` Result of running next phase.&#x20;
  {% endcolumn %}

{% column %}

<figure><img src="/files/bljfE7yo2pipjrILBYkJ" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### FinishDialogue

{% code overflow="wrap" %}

```
UDBS_DialogueBranch* UDBS_DialogueManager::FinishDialogueBranch()
```

{% endcode %}

{% columns %}
{% column %}
Finish current Dialogue Branch and return it.

If Dialogue Branch is not running, then this function does nothing.

Arguments:

`Return` Result Dialogue Branch.
{% endcolumn %}

{% column %}

<figure><img src="/files/LUFGedH71xVIPmwczM1l" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### FinishEvent

```
bool UDBS_DialogueManager::FinishEvent()
```

{% columns %}
{% column %}

Finish current Event Phase of Dialogue Branch.

If Dialogue Branch is not running or current phase is not Event Phase, then this function does nothing.

Arguments:

* `Return` True if Event Phase was finished, otherwise false.
  {% endcolumn %}

{% column %}

<figure><img src="/files/ptv8V5sLq2TyBO6YQ1RC" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### IsRunning

```
bool UDBS_DialogueManager::IsRunning() const
```

{% columns %}
{% column %}
Check Dialogue Branch is already running.
{% endcolumn %}

{% column %}

<figure><img src="/files/rfQzHHGLatd1PkKBcgYp" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### IsActiveEventPhase

```
bool UDBS_DialogueManager::IsActiveEventPhase() const
```

{% columns %}
{% column %}

Check Dialogue Branch is already running and current phase is Event Phase and not completed.

Arguments:

* `Return` True if current phase is Event Phase and not completed, otherwise false.
  {% endcolumn %}

{% column %}

<figure><img src="/files/Ud0L7ZUh49q5KCCktzN1" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### IsKnownPhase

```
bool UDBS_DialogueManager::IsKnownPhase(const FName& NameId) const
```

{% columns %}
{% column %}

Check if Dialogue Branch has phase with NameId.

Arguments:

* `NameId` Name of phase to check.
* `Return` True if phase with NameId is known, otherwise false.
  {% endcolumn %}

{% column %}

<figure><img src="/files/p91vjeO6oUZPHmxEuYuX" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gamewaycreator.gitbook.io/dbs-docs/control/dialogue-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
