Class TypewriterClip
Represents a single clip or segment in the typewriter sequencing system, managing its lifecycle via a state machine.
public class TypewriterClip
Inheritance
Remarks
A state machine is used because dialogue clips have distinct phases — character-by-character
reveal, hold/read time, and expire/dismiss — each with independent timing logic and entry
conditions. Encoding these as explicit states avoids the flag-forest that would otherwise
accumulate in a single Update method (e.g., isRevealing, isHolding,
isExpired all checked together), and makes it straightforward to add or reorder
phases without touching unrelated logic.
Constructors
TypewriterClip(BaseEntry, ITypewriterContext)
Constructs a new TypewriterClip instance with the specified entry and context. Automatically sets the clip start time and transitions to the initial BeginState.
public TypewriterClip(BaseEntry entry, ITypewriterContext context)
Parameters
| Name | Type | Description |
|---|---|---|
entry | BaseEntry | The typewriter entry associated with this clip. |
context | ITypewriterContext | The context in which the clip operates. |
Fields
Context
The context within which this clip operates.
public readonly ITypewriterContext Context
Field Value
ITypewriterContext
OnClipBegin
Event invoked when the clip begins.
public Action<BaseEntry, ITypewriterContext> OnClipBegin
Field Value
Action<BaseEntry, ITypewriterContext>
OnClipEnd
Event invoked when the clip duration ends.
public Action<BaseEntry, ITypewriterContext> OnClipEnd
Field Value
Action<BaseEntry, ITypewriterContext>
Remarks
Fires when the dialogue audio or animation for this clip finishes, signalling the sequencer that it should advance to the next clip. This is a content-completion event: the dialogue has been fully delivered but the UI card may still be visible during a hold/read period.
OnClipExpire
Event invoked when the clip's visual lifetime expires.
public Action<BaseEntry, ITypewriterContext> OnClipExpire
Field Value
Action<BaseEntry, ITypewriterContext>
Remarks
Fires when the UI display timeout lapses and the dialogue card should be dismissed from the screen. This is a presentation-lifetime event and is intentionally separate from OnClipEnd: because the read-hold period may extend beyond content playback, the two events occur at different times and drive different systems — sequencer advancement vs. UI dismiss animation — so each can be handled independently without coupling those two concerns.
OnClipUpdate
Event invoked every frame (or update cycle) while the clip is active.
public Action<BaseEntry, ITypewriterContext> OnClipUpdate
Field Value
Action<BaseEntry, ITypewriterContext>
Properties
ReadyToRelease
Indicates whether this clip has finished processing and is ready to be released.
public bool ReadyToRelease { get; }
Property Value
bool
Remarks
The null state is used as the completion sentinel rather than a dedicated boolean
flag because the state machine already owns the concept of "no further work to do":
when the final state calls ChangeState(null) it simultaneously clears the
update target and signals completion without any extra bookkeeping. The sequencer
can therefore poll this property without needing a separate event subscription.
Methods
ChangeState(IClipState)
Changes the current state of the clip, invoking the state's enter method. Passing null will clear the state and mark the clip as ready to release.
public void ChangeState(IClipState newState = null)
Parameters
| Name | Type | Description |
|---|---|---|
newState | IClipState | The new state to transition to, or null to clear. |