Class InstructionBase
Base class for all instructions.
Inheritance
Implements
Inherited Members
Namespace: SadConsole.Instructions
Assembly: SadConsole.dll
Syntax
public abstract class InstructionBase : UpdateComponent, IComponent
Constructors
InstructionBase()
Declaration
protected InstructionBase()
Properties
IsFinished
Flags the instruction as completed or not. If completed, the Finished event will be raised.
Declaration
public bool IsFinished { get; set; }
Property Value
Type | Description |
---|---|
bool |
RemoveOnFinished
When true, this instruction will automatically remove itself from the parent's SadComponents collection.
Declaration
public bool RemoveOnFinished { get; set; }
Property Value
Type | Description |
---|---|
bool |
RepeatCount
Indicates how many times this set will repeat. Use 0 to not repeat and -1 to repeat forever.
Declaration
public int RepeatCount { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
This property counts down each time the instruction finishes. If set to -1 it will repeat forever. As this represents how many times to repeat, setting this value to 1 would allow the instruction to execute twice, once for the original time, and again for the repeat counter of 1.
Methods
OnFinished(IScreenObject)
Called when the instruction finishes.
Declaration
protected virtual void OnFinished(IScreenObject componentHost)
Parameters
Type | Name | Description |
---|---|---|
IScreenObject | componentHost |
OnRepeating()
Called when the instruction repeats.
Declaration
protected virtual void OnRepeating()
OnStarted()
Called when the instruction first runs.
Declaration
protected virtual void OnStarted()
Repeat()
Repeats the current instruction. Decrements the RepeatCount value (if applicable), and raises the Repeating event. This method should be overridden in derived classes to customize how the object is reset for a repeat.
Declaration
public virtual void Repeat()
Reset()
Resets the Done flag.
Declaration
public virtual void Reset()
Remarks
On the base class, resets the IsFinished to false. Override this method to reset the derived class' counters and status flags for the instruction.
Update(IScreenObject, TimeSpan)
Executes the instruction. This base class method should be called from derived classes. If the IsFinished property is set to true, will try to repeat if needed and will raise all appropriate events.
Declaration
public override void Update(IScreenObject componentHost, TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
IScreenObject | componentHost | The object that hosts this instruction. |
TimeSpan | delta | The time that has elapsed since this method was last called. |
Overrides
Events
Finished
Raised when the instruction completes.
Declaration
public event EventHandler? Finished
Event Type
Type | Description |
---|---|
EventHandler |
Repeating
Raised when the instruction completes but is going to repeat.
Declaration
public event EventHandler? Repeating
Event Type
Type | Description |
---|---|
EventHandler |
Started
Raised when the instruction starts.
Declaration
public event EventHandler? Started
Event Type
Type | Description |
---|---|
EventHandler |