Class TextEffectSequencer
Runs a list of effects one after another, with optional pauses and callbacks between them.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public sealed class TextEffectSequencer
Remarks
Steps run in the order they were added. An effect step finishes when its effect does, so the sequence follows whatever pace the effects themselves keep rather than trying to predict it.
view.Effects.Play(TextEffects.Sequence()
.Then(TextEffects.Wipe(TextEffectDirection.RightToLeft).ToCleared(green, black))
.Call(() => DrawRoom(console, room))
.Wait(0.2f)
.Then(TextEffects.Typewriter(20, 2, room.Description, green, black)));
A sequence is not itself an effect and owns no cells. It hands each effect to the player in turn, so anything true of an effect played on its own stays true here: it can be skipped, it reports its own completion, and stopping it ends the sequence rather than advancing it, since a cancelled step has not finished.
Properties
Current
Gets the effect currently playing, or null between steps and once the sequence has ended.
Declaration
public ITextEffect Current { get; }
Property Value
| Type | Description |
|---|---|
| ITextEffect |
IsRunning
Gets whether the sequence is part way through.
Declaration
public bool IsRunning { get; }
Property Value
| Type | Description |
|---|---|
| bool |
StepCount
Gets the number of steps in the sequence, counting pauses and callbacks.
Declaration
public int StepCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Call(Action)
Adds a callback, which runs when the sequence reaches it.
Declaration
public TextEffectSequencer Call(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The callback to run. |
Returns
| Type | Description |
|---|---|
| TextEffectSequencer | This sequence, for chaining. |
Remarks
This is where a sequence redraws the screen between two effects, which is the usual reason for having one.
Loop(int)
Repeats the whole sequence.
Declaration
public TextEffectSequencer Loop(int times = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | times | How many times to run it in total. Zero or less loops forever. |
Returns
| Type | Description |
|---|---|
| TextEffectSequencer | This sequence, for chaining. |
Stop()
Ends the sequence and stops whatever step is currently playing.
Declaration
public void Stop()
Then(TextEffectBase)
Adds an effect to the end of the sequence.
Declaration
public TextEffectSequencer Then(TextEffectBase effect)
Parameters
| Type | Name | Description |
|---|---|---|
| TextEffectBase | effect | The effect to play. |
Returns
| Type | Description |
|---|---|
| TextEffectSequencer | This sequence, for chaining. |
Wait(float)
Adds a pause before the next effect.
Declaration
public TextEffectSequencer Wait(float seconds)
Parameters
| Type | Name | Description |
|---|---|---|
| float | seconds | How long to wait. |
Returns
| Type | Description |
|---|---|
| TextEffectSequencer | This sequence, for chaining. |
Remarks
The pause is applied as a start delay on the effect that follows it, so it is the player that waits rather than the sequence, and pausing the player pauses the wait along with everything else.
Events
OnCompleted
Raised when every step has run, and after the last repeat when the sequence loops.
Declaration
public event Action OnCompleted
Event Type
| Type | Description |
|---|---|
| Action |
OnStopped
Raised when the sequence ends early because one of its effects was stopped.
Declaration
public event Action OnStopped
Event Type
| Type | Description |
|---|---|
| Action |