InstructionBase Class
Definition
Section titled “Definition”Base class for all instructions.
public abstract class InstructionBase : UpdateComponent, IComponentInheritance object → UpdateComponent
Implements IComponent
Constructors
Section titled “Constructors”InstructionBase()
Section titled “InstructionBase()”protected InstructionBase()Properties
Section titled “Properties”RemoveOnFinished
Section titled “RemoveOnFinished”When true, this instruction will automatically remove itself from the parent’s SadComponents collection.
public bool RemoveOnFinished { get; set; }IsFinished
Section titled “IsFinished”Flags the instruction as completed or not. If completed, the Finished event will be raised.
public bool IsFinished { get; set; }RepeatCount
Section titled “RepeatCount”Indicates how many times this set will repeat. Use 0 to not repeat and -1 to repeat forever.
public int RepeatCount { get; set; }Remarks
Section titled “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
Section titled “Methods”Reset()
Section titled “Reset()”Resets the Done flag.
public virtual void Reset()Remarks
Section titled “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.
Repeat()
Section titled “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.
public virtual void Repeat()Update(IScreenObject, TimeSpan)
Section titled “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.
public override void Update(IScreenObject componentHost, TimeSpan delta)Parameters
Section titled “Parameters”componentHost IScreenObject
The object that hosts this instruction.
delta TimeSpan
The time that has elapsed since this method was last called.
OnFinished(IScreenObject)
Section titled “OnFinished(IScreenObject)”Called when the instruction finishes.
protected virtual void OnFinished(IScreenObject componentHost)Parameters
Section titled “Parameters”componentHost IScreenObject
OnRepeating()
Section titled “OnRepeating()”Called when the instruction repeats.
protected virtual void OnRepeating()OnStarted()
Section titled “OnStarted()”Called when the instruction first runs.
protected virtual void OnStarted()Events
Section titled “Events”Started
Section titled “Started”Raised when the instruction starts.
public event EventHandler? StartedEvent Type
Section titled “Event Type”Finished
Section titled “Finished”Raised when the instruction completes.
public event EventHandler? FinishedEvent Type
Section titled “Event Type”Repeating
Section titled “Repeating”Raised when the instruction completes but is going to repeat.
public event EventHandler? Repeating