Tasks
There is two types, Action and Conditions
public enum State
{
/// <summary> Initial State </summary>
Ready,
/// <summary> Executing </summary>
Running,
/// <summary> Execution finish with failure </summary>
Failure,
/// <summary> Execution finish with success </summary>
Success,
/// <summary> Execution finish was interrupted before finishing </summary>
Resting
}
Action Task
Used to execute some process that can be processed in an Async way, but it can be finished in a Sync way if you call EndAction
inside of the StartAction
or at the first iteration of UpdateAction
protected virtual void StartAction();
protected virtual void UpdateAction();
protected virtual void StopAction();
protected void EndAction(bool successful = true)
Condition Task
When a ConditionTask is active, StartCondition is first called before the first CheckCondition check, and StopCondition is called when the ConditionTask is deactivated, such as when switching to another state.
It is recommended to use this to your advantage to do some pre-definition that will guarantee more performance, such as defining variables and subscription and unsubscription events.
public virtual void StartCondition();
public abstract bool CheckCondition();
public virtual void StopCondition();