DialogActionRunner API

DialogActionRunner dispatches an ActionNode to matching UnityEvent bindings and asynchronous handlers. DialogManager resolves the runner and exposes coroutine-backed convenience calls.

Responsibilities

  • invoke matching synchronous UnityEvent bindings from the conversation-specific set and, when configured, the global set
  • run coroutine handlers implementing IActionHandler; contextual handlers can also implement IContextualDialogueActionHandler
  • select action sets by dialogID and optionally use the global fallback
  • honor an action node’s pre-delay and wait-for-completion settings

Convenience methods

Call these from a MonoBehaviour with a configured runner. waitForCompletion waits for the handler coroutine; the handler must itself yield until its gameplay work is finished.

StartCoroutine(actionRunner.RunActionGlobal(
    actionId: "PlaySfx",
    payloadJson: "{\"clip\":\"ding\"}",
    waitForCompletion: false));
StartCoroutine(actionRunner.RunActionForDialogue(
    dialogId: "intro_guard",
    actionId: "UnlockGate",
    payloadJson: "{\"gateId\":\"north\"}",
    waitForCompletion: true));

Async handler example

using System.Collections;
using DialogSystem.Runtime.Interfaces;
using UnityEngine;

public class UnlockGateHandler : MonoBehaviour, IActionHandler
{
    public bool CanHandle(string actionId) => actionId == "UnlockGate";

    public IEnumerator Handle(string actionId, string payloadJson)
    {
        Debug.Log($"Unlock gate with payload: {payloadJson}");
        yield return null;
    }
}

Place the handler on a GameObject referenced by the matching ConversationActionSet (or global set), and make CanHandle match the action node’s exact ID. The manager uses its configured runner and can discover an available runner when none is assigned. For gameplay code, DialogManager.InvokeDialogueAction and InvokeGlobalAction provide manager-level wrappers.