Skip to content

InstructionBase Class

Base class for all instructions.

C#
public abstract class InstructionBase : UpdateComponent, IComponent

Inheritance objectUpdateComponent

Implements IComponent

C#
protected InstructionBase()

When true, this instruction will automatically remove itself from the parent’s SadComponents collection.

C#
public bool RemoveOnFinished { get; set; }

Flags the instruction as completed or not. If completed, the Finished event will be raised.

C#
public bool IsFinished { get; set; }

Indicates how many times this set will repeat. Use 0 to not repeat and -1 to repeat forever.

C#
public int RepeatCount { get; set; }

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.

Resets the Done flag.

C#
public virtual void Reset()

On the base class, resets the IsFinished to false. Override this method to reset the derived class’ counters and status flags for the instruction.

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.

C#
public virtual void Repeat()

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.

C#
public override void Update(IScreenObject componentHost, TimeSpan delta)

componentHost IScreenObject
The object that hosts this instruction.

delta TimeSpan
The time that has elapsed since this method was last called.

Called when the instruction finishes.

C#
protected virtual void OnFinished(IScreenObject componentHost)

componentHost IScreenObject

Called when the instruction repeats.

C#
protected virtual void OnRepeating()

Called when the instruction first runs.

C#
protected virtual void OnStarted()

Raised when the instruction starts.

C#
public event EventHandler? Started

EventHandler

Raised when the instruction completes.

C#
public event EventHandler? Finished

EventHandler

Raised when the instruction completes but is going to repeat.

C#
public event EventHandler? Repeating

EventHandler