Interface ITextEffectContext
The services a running text effect needs from whatever is hosting it: somewhere to write, a glyph cache to stamp with, and pooled scratch storage.
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public interface ITextEffectContext
Remarks
TextModeEffectPlayer is the implementation used in a live scene. The interface exists so effects can also be driven by a test double that wraps a bare CellGrid, which is what keeps every effect unit-testable without a view, a camera or a GPU.
Anything rented from a context must be returned to the same context. Effects do that in their release path, so game code never handles rentals directly.
Properties
CellAspect
Gets the width of a cell divided by its height, which effects use to keep radial and diagonal shapes from coming out stretched. Cells are typically about twice as tall as they are wide, so this is usually around 0.5.
Declaration
float CellAspect { get; }
Property Value
| Type | Description |
|---|---|
| float |
Console
Gets the high-level writer over Grid, for effects that print text rather than stamping individual cells.
Declaration
TextModeConsole Console { get; }
Property Value
| Type | Description |
|---|---|
| TextModeConsole |
GlyphCache
Gets the glyph cache used to stamp codepoints an effect introduces itself. Effects that only move or recolor existing cells do not need it.
Declaration
GlyphAtlasCache GlyphCache { get; }
Property Value
| Type | Description |
|---|---|
| GlyphAtlasCache |
Grid
Gets the grid effects write into. Never null while an effect is bound.
Declaration
CellGrid Grid { get; }
Property Value
| Type | Description |
|---|---|
| CellGrid |
Methods
RentBuffer()
Rents a cell buffer for the duration of an effect.
Declaration
CellBuffer RentBuffer()
Returns
| Type | Description |
|---|---|
| CellBuffer | A buffer holding nothing, ready to be resized and captured into. |
RentThresholds(int)
Rents a float array of at least the requested length, for per-cell threshold values.
Declaration
float[] RentThresholds(int minimumLength)
Parameters
| Type | Name | Description |
|---|---|---|
| int | minimumLength | Smallest acceptable array length. |
Returns
| Type | Description |
|---|---|
| float[] | An array of at least |
Remarks
The array may be longer than requested and its contents are undefined, so fill every entry that will be read before reading any of them.
ReturnBuffer(CellBuffer)
Returns a previously rented cell buffer.
Declaration
void ReturnBuffer(CellBuffer buffer)
Parameters
| Type | Name | Description |
|---|---|---|
| CellBuffer | buffer | The buffer to return. Null is ignored. |
ReturnThresholds(float[])
Returns a previously rented threshold array.
Declaration
void ReturnThresholds(float[] thresholds)
Parameters
| Type | Name | Description |
|---|---|---|
| float[] | thresholds | The array to return. Null is ignored. |
TryRenderScratch(Action<TextModeConsole>, in CellRect, CellBuffer)
Draws something onto a scratch grid and captures a region of the result, without disturbing what is currently on screen.
Declaration
bool TryRenderScratch(Action<TextModeConsole> draw, in CellRect region, CellBuffer destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<TextModeConsole> | draw | Callback that draws the target state. |
| CellRect | region | The block of cells to capture from the result. |
| CellBuffer | destination | Buffer to capture into. |
Returns
| Type | Description |
|---|---|
| bool | True if the target was drawn and captured. |
Remarks
This is how a transition gets hold of the screen it is transitioning to. The callback is handed a console over a spare grid the same size as the live one and writes to it exactly as it would to the real thing, in full-grid coordinates, so game code that draws a screen needs no special version for transitions.
The scratch grid is cleared before the callback runs and is reused between calls, so nothing survives from one transition to the next.