//
using Code.StateMachine;
using Code.Debug.States;
using Code.Debug.States;
namespace Code.Debug
{
public partial class DebugStateMachine : AbstractStateMachine
{
public DebugStateMachine()
{
var stateFirstState = new FirstState(StateMachineContext);
States.Add(stateFirstState.myState, stateFirstState);
var stateSecondState = new SecondState(StateMachineContext);
States.Add(stateSecondState.myState, stateSecondState);
CurrentBaseState = States[default(Code.Debug.DebugStates)];
}
protected override bool CheckTransitionAllowed(Code.Debug.DebugStates nextState) => AllowedStates.HasFlag(nextState);
protected override void ResetAllowedTransitions() => AllowedStates = 0;
}
public static class DebugStateMachineExtensions
{
public static AbstractStateMachine AllowStateTransition(
this AbstractStateMachine stateMachine, Code.Debug.DebugStates state)
{
if (stateMachine == null) return null;
stateMachine.AllowedStates |= state;
return stateMachine;
}
}
}