/// <summary> /// Transition this HSM to a new state. /// </summary> /// <param name="state"> The state to transition to. </param> public void TransitionTo(IHState <SIG, CTX> state) { if (state != currentState) { currentState.Exit(); currentState = state; currentState.Enter(); } }
/// <summary> /// Start this state machine. Enters the current state. /// </summary> public void Start() { if (!running) { running = true; System.Diagnostics.Debug.WriteLine($"Starting {GetType()}"); currentState.Enter(); } else { throw new Exception("HSM is already running!"); } }