Skip to main content

Action Components

EstuaryActionManager

MonoBehaviour -- Routes action tags from bot responses to handlers via Inspector bindings or code callbacks.

Namespace: Estuary

Inspector Fields

FieldTypeDefaultDescription
CharactersList<EstuaryCharacter>Characters to watch. If empty, watches the active character
ActionBindingsList<ActionBinding>Name-to-UnityEvent mappings

ActionBinding

Each binding maps an action name to a UnityEvent:

FieldTypeDescription
ActionNamestringThe action name to match (e.g., "wave")
OnActionUnityEvent<AgentAction>UnityEvent invoked when the action fires

Methods

MethodReturnsDescription
AddCharacter(EstuaryCharacter character)voidStart watching a character at runtime
RemoveCharacter(EstuaryCharacter character)voidStop watching a character
InvokeAction(string actionName, Dictionary<string, string> parameters = null)voidProgrammatically invoke an action (goes through the same handler path as AI actions)

Events

EventSignatureDescription
OnAnyActionReceivedAction<AgentAction>Fires for every action from any watched character

Inspector Setup

  1. Add the Estuary Action Manager component to a GameObject
  2. Drag EstuaryCharacter references into the Characters list (or leave empty for auto-active)
  3. Add entries to Action Bindings:
    • Set the Action Name (e.g., wave)
    • Wire the On Action UnityEvent to your handler method

Code Setup

using Estuary;
using Estuary.Models;

public class MyActionHandler : MonoBehaviour
{
[SerializeField] private EstuaryActionManager actionManager;

void Start()
{
actionManager.OnAnyActionReceived += HandleAction;
}

void HandleAction(AgentAction action)
{
Debug.Log($"Action: {action.Name}");
foreach (var param in action.Parameters)
{
Debug.Log($" {param.Key} = {param.Value}");
}
}
}

ActionParser

Static utility class for parsing <action> XML tags from text.

Namespace: Estuary.Utilities

Methods

MethodReturnsDescription
ParseActions(string text)List<AgentAction>Extract all <action> tags and return as AgentAction objects
StripActions(string text)stringRemove all <action> tags from text, returning clean text
ParseAndStrip(string text, out List<AgentAction> actions)stringParse actions and return stripped text in one pass
ContainsActions(string text)boolCheck if text contains any <action> tags

Tag Format

Actions use self-closing XML tags. The name attribute is required; all other attributes become parameters.

<!-- Basic action -->
<action name="wave" />

<!-- Action with parameters -->
<action name="navigate" target="door" speed="walk" />

<!-- Multiple actions -->
<action name="navigate" target="player" /> <action name="wave" />

Usage

using Estuary.Utilities;
using Estuary.Models;

string raw = "Hello! <action name=\"wave\" /> Let me walk over. <action name=\"navigate\" target=\"player\" />";

// Parse actions
List<AgentAction> actions = ActionParser.ParseActions(raw);
// actions[0].Name = "wave"
// actions[1].Name = "navigate", actions[1].GetParameter("target") = "player"

// Strip actions
string clean = ActionParser.StripActions(raw);
// clean = "Hello! Let me walk over. "

// Parse and strip in one call
string text = ActionParser.ParseAndStrip(raw, out var parsedActions);

// Quick check
bool hasActions = ActionParser.ContainsActions(raw); // true