45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
|
|
// <auto-generated/>
|
|
using Code.StateMachine;
|
|
|
|
using Code.Debug.States;
|
|
|
|
using Code.Debug.States;
|
|
|
|
namespace Code.Debug
|
|
{
|
|
|
|
public partial class DebugStateMachine : AbstractStateMachine<Code.Debug.DebugStates,Code.Debug.DebugStateMachineContext>
|
|
{
|
|
|
|
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<Code.Debug.DebugStates, Code.Debug.DebugStateMachineContext> AllowStateTransition(
|
|
this AbstractStateMachine<Code.Debug.DebugStates, Code.Debug.DebugStateMachineContext> stateMachine, Code.Debug.DebugStates state)
|
|
{
|
|
if (stateMachine == null) return null;
|
|
|
|
stateMachine.AllowedStates |= state;
|
|
return stateMachine;
|
|
}
|
|
}
|
|
}
|
|
|