Interface IEntryResponser<T>
Generic interface for handling typewriter entries of a specific subtype of BaseEntry. Inherits from IEntryResponser to support both strongly-typed and loosely-typed entry processing.
public interface IEntryResponser<T> : IEntryResponser where T : BaseEntry
Type Parameters
| Name | Type | Description |
|---|---|---|
T | A subtype of BaseEntry that this responder specializes in processing. |
Implements
Examples
Implement IEntryResponser on a MonoBehaviour to react to a specific
entry type. The non-generic HandleEntry overload is the runtime
dispatch path called by TypewriterSequencer; the generic overload is where the
strongly-typed logic lives. [RequireComponent] guarantees a TypewriterActor
is always present on the same GameObject so the sequencer can find this responder via the
actor lookup:
using Aarthificial.Typewriter;
using Aarthificial.Typewriter.Entries;
using mobisim.Dialogue;
using UnityEngine;
[RequireComponent(typeof(TypewriterActor))]
public class SpeechBubbleResponse : MonoBehaviour, IEntryResponser
{
[SerializeField] private GameObject _bubblePrefab;
// Non-generic fallback — called by TypewriterSequencer's runtime dispatch.
public void HandleEntry(BaseEntry entry, ITypewriterContext context)
=> HandleEntry(entry as DialogueEntry, context);
// Strongly-typed handler — implement actual display logic here.
public void HandleEntry(DialogueEntry entry, ITypewriterContext context)
{
if (entry == null) return;
var bubble = Instantiate(_bubblePrefab, transform);
bubble.GetComponentInChildren().text = entry.Text;
}
}
// Add SpeechBubbleResponse alongside TypewriterActor on the character GameObject.
// TypewriterSequencer resolves it automatically via gameObject.GetEntryResponser(entry).
Remarks
Each actor can have multiple responders implementing this interface for different entry types. If multiple responders for the same entry type exist on a single actor, only one will process the entry.
Methods
HandleEntry(T, ITypewriterContext)
Handles an incoming typewriter entry of type T.
void HandleEntry(T entry, ITypewriterContext context)
Parameters
| Name | Type | Description |
|---|---|---|
entry | T | The strongly-typed typewriter entry to process. |
context | ITypewriterContext | The context instance providing access to blackboards and runtime data shared with other entries in the same scope. |