Skip to content

CodeEffect Class

Effect that runs code for the apply and update actions of an effect.

C#
public class CodeEffect : CellEffectBase, ICellEffect

Inheritance objectCellEffectBase

Implements ICellEffect

CodeEffect(string, Func<CodeEffect, ColoredGlyphBase, ColoredGlyphBase, bool>, Action<CodeEffect, TimeSpan>, Action<CodeEffect>)

Section titled “CodeEffect(string, Func<CodeEffect, ColoredGlyphBase, ColoredGlyphBase, bool>, Action<CodeEffect, TimeSpan>, Action<CodeEffect>)”

Creates a cell effect that runs custom code instead of hardcoded effect actions.

C#
public CodeEffect(string id, Func<CodeEffect, ColoredGlyphBase, ColoredGlyphBase, bool> apply, Action<CodeEffect, TimeSpan> update, Action<CodeEffect> restart)

id string
A user-definable identifier.

apply Func<CodeEffect, ColoredGlyphBase, ColoredGlyphBase, bool>
The code to run for ApplyToCell(ColoredGlyphBase, ColoredGlyphBase).

update Action<CodeEffect, TimeSpan>
The code to run for Update(TimeSpan).

restart Action<CodeEffect>
The code to run for Restart().

A user defined identifier of the effect.

C#
public string Id { get; set; }

An object associated with this effect.

C#
public object? Tag { get; set; }

When true, uses the Duration timer to stop this effect; otherwise false.

C#
public bool UseDuration { get; set; }

The amount of time this effect runs for in seconds.

C#
public TimeSpan Duration { get; set; }

ApplyToCell(ColoredGlyphBase, ColoredGlyphBase)

Section titled “ApplyToCell(ColoredGlyphBase, ColoredGlyphBase)”

Applies the state of the effect to a cell.

C#
public override bool ApplyToCell(ColoredGlyphBase cell, ColoredGlyphBase originalState)

cell ColoredGlyphBase
The surface cell using this effect.

originalState ColoredGlyphBase
The state of the cell prior to the effect being applied.

bool
true when this method modified the cell; otherwise false.

Not supported.

C#
public override ICellEffect Clone()

ICellEffect

Updates the state of the effect.

C#
public override void Update(TimeSpan delta)

delta TimeSpan
Time since the last call to this effect.

Restarts the cell effect.

C#
public override void Restart()
C#
public override string ToString()

string