Class TransitionEffectBase
Base class for effects that move a region from what is on screen now to something else.
Inheritance
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public abstract class TransitionEffectBase : TextEffectBase, ITextEffect, IDisposable
Remarks
Every transition needs two pictures: the region as it looks when the effect starts, and the region as it should look when the effect ends. The first is captured automatically. The second is supplied in one of three ways, and a transition given none of them transitions to a blank region, which is what a fade to black wants.
effect.To(console => DrawInventoryScreen(console)); // draw it on demand
effect.To(someOtherGrid); // copy it from a grid
effect.ToCleared(green, black); // transition to blank
The draw callback is the usual choice. It runs once when the effect starts, against a scratch grid the same size as the real one, and receives full-grid coordinates, so the same drawing code that paints a screen normally can paint the target of a transition.
Properties
FromState
Gets the region as it looked when the effect started. Valid from OnTransitionStart() onward.
Declaration
protected CellBuffer FromState { get; }
Property Value
| Type | Description |
|---|---|
| CellBuffer |
ToState
Gets the region as it should look when the effect ends. Valid from OnTransitionStart() onward.
Declaration
protected CellBuffer ToState { get; }
Property Value
| Type | Description |
|---|---|
| CellBuffer |
Methods
OnEffectFinish(bool)
Called when the effect finishes, whether it completed, was skipped or was stopped.
Declaration
protected override sealed void OnEffectFinish(bool completed)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | completed | True when the effect reached its final state. |
Overrides
Remarks
The default implementation does nothing. Override it to restore state an effect borrowed, which is what a corrupting effect needs so the grid is not left damaged.
OnEffectRelease()
Called when the effect is disposed. Return anything rented from the context here.
Declaration
protected override void OnEffectRelease()
Overrides
OnEffectStart()
Called when the effect starts, after the region is resolved and before any tick. Capture whatever the effect needs from the grid here.
Declaration
protected override sealed void OnEffectStart()
Overrides
OnTransitionFinish(bool)
Called when the effect finishes, before the target state is written.
Declaration
protected virtual void OnTransitionFinish(bool completed)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | completed | True when the effect reached its final state. |
OnTransitionStart()
Called when the effect starts, after both the starting and target states are ready.
Declaration
protected virtual void OnTransitionStart()
SetClearedTarget(Color32, Color32)
Transitions to a blank region in the given colors.
Declaration
public void SetClearedTarget(Color32 foreground, Color32 background)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | foreground | Foreground color of the blank cells. |
| Color32 | background | Background color of the blank cells. |
SetTarget(CellGrid)
Transitions to the matching region of another grid.
Declaration
public void SetTarget(CellGrid grid)
Parameters
| Type | Name | Description |
|---|---|---|
| CellGrid | grid | Grid holding the target state. |
SetTarget(Action<TextModeConsole>)
Transitions to whatever the callback draws.
Declaration
public void SetTarget(Action<TextModeConsole> draw)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<TextModeConsole> | draw | Callback that paints the target state. |
Remarks
The callback runs once, when the effect starts, against a scratch grid rather than the live one. It is handed full-grid coordinates, so ordinary drawing code works unchanged.