public enum States { Idle, Moving } public void SetupStateMachine() { StateMachinestateMachine = new StateMachine (States.Idle); stateMachine.AddAutomaticTransition(States.Idle, States.Moving, () => true); stateMachine.AddAutomaticTransition(States.Moving, States.Idle, () => false); }
public void ExampleStateMachine() { StateMachineIn this example, we create a state machine that represents the state of a task. We start in the `Off` state, and automatically transition to `On` when a condition is met (in this case, resources are loaded and ready). We also automatically transition back to `Off` when another condition is met (in this case, the task is complete). The StateMachine package library is likely the Stateless package.stateMachine = new StateMachine ("Off"); stateMachine.AddAutomaticTransition("Off", "On", () => CheckIfReady()); stateMachine.AddAutomaticTransition("On", "Off", () => CheckIfComplete()); } private bool CheckIfReady() { // Check if resources are loaded and ready return true; } private bool CheckIfComplete() { // Check if task is complete return true; }