Class CodeEffect
Effect that runs code for the apply and update actions of an effect.
Implements
Inherited Members
Namespace: SadConsole.Effects
Assembly: SadConsole.dll
Syntax
public class CodeEffect : CellEffectBase, ICellEffect
Constructors
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.
Declaration
public CodeEffect(string id, Func<CodeEffect, ColoredGlyphBase, ColoredGlyphBase, bool> apply, Action<CodeEffect, TimeSpan> update, Action<CodeEffect> restart)
Parameters
Type | Name | Description |
---|---|---|
string | id | A user-definable identifier. |
Func<CodeEffect, ColoredGlyphBase, ColoredGlyphBase, bool> | apply | The code to run for ApplyToCell(ColoredGlyphBase, ColoredGlyphBase). |
Action<CodeEffect, TimeSpan> | update | The code to run for Update(TimeSpan). |
Action<CodeEffect> | restart | The code to run for Restart(). |
Properties
Duration
The amount of time this effect runs for in seconds.
Declaration
public TimeSpan Duration { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Id
A user defined identifier of the effect.
Declaration
public string Id { get; set; }
Property Value
Type | Description |
---|---|
string |
Tag
An object associated with this effect.
Declaration
public object? Tag { get; set; }
Property Value
Type | Description |
---|---|
object |
UseDuration
Declaration
public bool UseDuration { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
ApplyToCell(ColoredGlyphBase, ColoredGlyphBase)
Applies the state of the effect to a cell.
Declaration
public override bool ApplyToCell(ColoredGlyphBase cell, ColoredGlyphBase originalState)
Parameters
Type | Name | Description |
---|---|---|
ColoredGlyphBase | cell | The surface cell using this effect. |
ColoredGlyphBase | originalState | The state of the cell prior to the effect being applied. |
Returns
Overrides
Clone()
Not supported.
Declaration
public override ICellEffect Clone()
Returns
Type | Description |
---|---|
ICellEffect |
Overrides
Restart()
Restarts the cell effect.
Declaration
public override void Restart()
Overrides
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
Update(TimeSpan)
Updates the state of the effect.
Declaration
public override void Update(TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | delta | Time since the last call to this effect. |