Skip to content

LSDE Dialog Engine / DialogueEngine

Class: DialogueEngine

Defined in: engine.ts:25

LSDE Dialog Engine — callback-driven graph dispatcher.

Implements

Constructors

Constructor

new DialogueEngine(): DialogueEngine

Returns

DialogueEngine

Methods

getActiveScenes()

getActiveScenes(): SceneHandle[]

Defined in: engine.ts:145

Get all currently active scene handles.

Returns

SceneHandle[]

Implementation of

IDialogueEngine.getActiveScenes


getCurrentBlocks()

getCurrentBlocks(): BlueprintBlock[]

Defined in: engine.ts:149

Get the current block of every active scene.

Returns

BlueprintBlock[]

Implementation of

IDialogueEngine.getCurrentBlocks


getSceneConnections()

getSceneConnections(sceneId): BlueprintConnection[]

Defined in: engine.ts:158

Get connections for a scene (for inter-scene navigation).

Parameters

sceneId

string

Returns

BlueprintConnection[]

Implementation of

IDialogueEngine.getSceneConnections


init()

init(options): DiagnosticReport

Defined in: engine.ts:41

Validate blueprint data, build internal graph, return diagnostic report.

Parameters

options

InitOptions

Returns

DiagnosticReport

Implementation of

IDialogueEngine.init


isRunning()

isRunning(): boolean

Defined in: engine.ts:141

True if at least one scene is active.

Returns

boolean

Implementation of

IDialogueEngine.isRunning


onAction()

onAction(handler): void

Defined in: engine.ts:102

Register a global handler for ACTION blocks. The developer MUST handle execution in this handler.

Parameters

handler

ActionHandler

Returns

void

Implementation of

IDialogueEngine.onAction


onBeforeBlock()

onBeforeBlock(handler): void

Defined in: engine.ts:86

Register a handler called before every block. Must call resolve() to continue.

Parameters

handler

BeforeBlockHandler

Returns

void

Implementation of

IDialogueEngine.onBeforeBlock


onChoice()

onChoice(handler): void

Defined in: engine.ts:94

Register a global handler for CHOICE blocks. All choices are provided, tagged with visible when onResolveCondition() is configured.

Parameters

handler

ChoiceHandler

Returns

void

Implementation of

IDialogueEngine.onChoice


onCondition()

onCondition(handler): void

Defined in: engine.ts:98

Register a global handler for CONDITION blocks. The developer MUST handle evaluation in this handler.

Parameters

handler

ConditionHandler

Returns

void

Implementation of

IDialogueEngine.onCondition


onDialog()

onDialog(handler): void

Defined in: engine.ts:90

Register a global handler for DIALOG blocks. May return a cleanup function.

Parameters

handler

DialogHandler

Returns

void

Implementation of

IDialogueEngine.onDialog


onInvalidateBlock()

onInvalidateBlock(handler): void

Defined in: engine.ts:82

Register a handler called when a block fails validation.

Parameters

handler

InvalidateBlockHandler

Returns

void

Implementation of

IDialogueEngine.onInvalidateBlock


onResolveCharacter()

onResolveCharacter(fn): void

Defined in: engine.ts:65

Register a global character resolver. Called for every block with metadata.characters.

Parameters

fn

(characters) => BlockCharacter | undefined

Returns

void

Implementation of

IDialogueEngine.onResolveCharacter


onResolveCondition()

onResolveCondition(evaluator): void

Defined in: engine.ts:69

Install a unified condition evaluator for both choice visibility and condition block pre-evaluation. The engine handles choice: conditions internally via choice history — this callback evaluates game-state conditions only.

When installed:

  • Choice blocks: each choice is tagged with visible: true | false based on its visibilityConditions.
  • Condition blocks: each group is pre-evaluated and the result is available in context.groups[i].result and context.evaluation.

Parameters

evaluator

(condition) => boolean

Returns

void

Implementation of

IDialogueEngine.onResolveCondition


onSceneEnter()

onSceneEnter(handler): void

Defined in: engine.ts:106

Register a handler called when any scene starts.

Parameters

handler

SceneLifecycleHandler

Returns

void

Implementation of

IDialogueEngine.onSceneEnter


onSceneExit()

onSceneExit(handler): void

Defined in: engine.ts:110

Register a handler called when any scene ends (natural or cancelled).

Parameters

handler

SceneLifecycleHandler

Returns

void

Implementation of

IDialogueEngine.onSceneExit


onValidateNextBlock()

onValidateNextBlock(handler): void

Defined in: engine.ts:78

Register a handler called before each block to validate it.

Parameters

handler

ValidateNextBlockHandler

Returns

void

Implementation of

IDialogueEngine.onValidateNextBlock


scene()

scene(sceneId): SceneHandle

Defined in: engine.ts:114

Create a scene handle. Does NOT start the flow — call handle.start().

Parameters

sceneId

string

Returns

SceneHandle

Implementation of

IDialogueEngine.scene


setChoiceFilter()

setChoiceFilter(evaluator): void

Defined in: engine.ts:74

Parameters

evaluator

(condition) => boolean

Returns

void

Deprecated

Use onResolveCondition() instead.

Implementation of

IDialogueEngine.setChoiceFilter


setLocale()

setLocale(locale): void

Defined in: engine.ts:52

Set the active locale for text resolution.

Parameters

locale

string

Returns

void

Implementation of

IDialogueEngine.setLocale


stop()

stop(): void

Defined in: engine.ts:135

Stop all active scenes.

Returns

void

Implementation of

IDialogueEngine.stop