Action Components
EstuaryActionManager
MonoBehaviour -- Routes action tags from bot responses to handlers via Inspector bindings or code callbacks.
Namespace: Estuary
Inspector Fields
| Field | Type | Default | Description |
|---|---|---|---|
Characters | List<EstuaryCharacter> | — | Characters to watch. If empty, watches the active character |
ActionBindings | List<ActionBinding> | — | Name-to-UnityEvent mappings |
ActionBinding
Each binding maps an action name to a UnityEvent:
| Field | Type | Description |
|---|---|---|
ActionName | string | The action name to match (e.g., "wave") |
OnAction | UnityEvent<AgentAction> | UnityEvent invoked when the action fires |
Methods
| Method | Returns | Description |
|---|---|---|
AddCharacter(EstuaryCharacter character) | void | Start watching a character at runtime |
RemoveCharacter(EstuaryCharacter character) | void | Stop watching a character |
InvokeAction(string actionName, Dictionary<string, string> parameters = null) | void | Programmatically invoke an action (goes through the same handler path as AI actions) |
Events
| Event | Signature | Description |
|---|---|---|
OnAnyActionReceived | Action<AgentAction> | Fires for every action from any watched character |
Inspector Setup
- Add the Estuary Action Manager component to a GameObject
- Drag
EstuaryCharacterreferences into the Characters list (or leave empty for auto-active) - Add entries to Action Bindings:
- Set the Action Name (e.g.,
wave) - Wire the On Action UnityEvent to your handler method
- Set the Action Name (e.g.,
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
| Method | Returns | Description |
|---|---|---|
ParseActions(string text) | List<AgentAction> | Extract all <action> tags and return as AgentAction objects |
StripActions(string text) | string | Remove all <action> tags from text, returning clean text |
ParseAndStrip(string text, out List<AgentAction> actions) | string | Parse actions and return stripped text in one pass |
ContainsActions(string text) | bool | Check 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