Table of Contents

Class NPCDialogue

Namespace
S1API.Entities
Assembly
S1API.dll

Modder-facing dialogue wrapper for an NPC. Provides helpers to create interactive conversations with branching dialogue trees, choice-based interactions, and dynamic responses. Use BuildAndRegisterContainer(string, Action<DialogueContainerBuilder>) to define custom conversations.

public sealed class NPCDialogue
Inheritance
NPCDialogue
Inherited Members
Extension Methods

Remarks

Dialogue configuration is done in OnCreated(). Use BuildAndSetDatabase(Action<DialogueDatabaseBuilder>) for dialogue entries and BuildAndRegisterContainer(string, Action<DialogueContainerBuilder>) for conversation flows. Subscribe to choice and node events for dynamic dialogue behavior.

Properties

IsDialogueInProgress

Whether a dialogue is currently in progress for this NPC.

public bool IsDialogueInProgress { get; }

Property Value

bool

Methods

BuildAndRegisterContainer(string, Action<DialogueContainerBuilder>)

Builds a DialogueContainer with choice-based flow and registers it by name. Use this to define custom conversations for this NPC entirely from code.

If a custom NPC, you must also call BuildAndSetDatabase for this to work

public void BuildAndRegisterContainer(string containerName, Action<DialogueContainerBuilder> configure)

Parameters

containerName string
configure Action<DialogueContainerBuilder>

BuildAndSetDatabase(Action<DialogueDatabaseBuilder>)

Builds a dialogue database at runtime from string data and installs it on this NPC. Does not require asset bundles.

public void BuildAndSetDatabase(Action<DialogueDatabaseBuilder> configure)

Parameters

configure Action<DialogueDatabaseBuilder>

ClearCallbacks()

Removes all registered dialogue callbacks for this NPC.

public void ClearCallbacks()

End()

Ends any active dialogue.

public void End()

JumpTo(string, string, bool)

Immediately navigates this NPC's dialogue to a specific container and entry node. Returns true on success.

public bool JumpTo(string containerName, string entryNodeLabel, bool enableBehaviour = false)

Parameters

containerName string
entryNodeLabel string
enableBehaviour bool

Returns

bool

OnChoiceSelected(string, Action)

Register a callback to run when a choice with the given label is selected. Label must match the DialogueChoiceData.ChoiceLabel in your container.

public NPCDialogue OnChoiceSelected(string choiceLabel, Action callback)

Parameters

choiceLabel string
callback Action

Returns

NPCDialogue

OnConversationStart(Action)

Register a callback to run when a conversation starts with this NPC. This fires before the dialogue is displayed, allowing you to prepare or rebuild dialogue containers.

public NPCDialogue OnConversationStart(Action callback)

Parameters

callback Action

Returns

NPCDialogue

OnNodeDisplayed(string, Action)

Register a callback to run when a dialogue node with the given label is displayed.

public NPCDialogue OnNodeDisplayed(string nodeLabel, Action callback)

Parameters

nodeLabel string
callback Action

Returns

NPCDialogue

OverrideText(string)

Overrides the shown dialogue text (e.g., for temporary notifications). You generally won't want to use this

public void OverrideText(string text)

Parameters

text string

PlayReaction(string, float, bool)

Plays a reaction by key. If duration is -1 the underlying system decides duration.

public void PlayReaction(string key, float durationSeconds = -1, bool network = false)

Parameters

key string
durationSeconds float
network bool

ShowWorldText(string, float)

Shows worldspace dialogue text at the NPC for a duration.

public void ShowWorldText(string text, float durationSeconds)

Parameters

text string
durationSeconds float

Start(string, bool, string)

Starts a dialogue by container name present on the NPC's handler.

public void Start(string containerName, bool enableBehaviour = true, string entryNodeLabel = "ENTRY")

Parameters

containerName string
enableBehaviour bool
entryNodeLabel string

StopOverride()

Stops any active override and resumes normal dialogue display.

public void StopOverride()

UseContainerOnInteract(string)

When the player interacts with this NPC, force using the named container for the next dialogue. Returns true if the container was found and applied.

public bool UseContainerOnInteract(string containerName)

Parameters

containerName string

Returns

bool

UseContainerOnInteractOnce(string)

When the player interacts with this NPC, force using the named container once for the next dialogue. After the conversation begins, the override is automatically cleared so subsequent interactions use normal flow. Returns true if the container was found and applied.

public bool UseContainerOnInteractOnce(string containerName)

Parameters

containerName string

Returns

bool