BehaviorScripts use two distinct paths for communication:
1. Manifest-declared Signals (Preferred)
Declared in the manifest.signals array with direction: "listen" or "both". These are automatically subscribed via the global SignalBus and routed to the onSignal(name, payload) hook. This path is typed and visible to Editors/AI.
- Emit: Use
ctx.emitSignal('name', payload) or BehaviorScriptSystem.emitSignal(...). - Direct Invoke: Use
BehaviorScriptSystem.dispatchSignal(name, payload, target?) to bypass manifest requirements.
2. Manifest-declared Events
Declared in manifest.events. These are routed to the onEvent(name, payload, target) hook. Supported targets include "self", "component", "gameObject", or a custom string provided during system initialization.
3. Local Subscriptions
Use ctx.onSignal(name, listener) or ctx.onEvent(target, name, listener) for dynamic, local subscriptions inside setup(). These are automatically cleaned up on detachment. Failures in these listeners are reported as phase: "signal" or phase: "event" diagnostics.