public CastleStateMachine() { CurrentState = CastleProcessState.Inactive; transitions = new Dictionary <StateTransition, CastleProcessState> { { new StateTransition(CastleProcessState.Inactive, CastleCommand.Exit), CastleProcessState.Terminated }, { new StateTransition(CastleProcessState.Inactive, CastleCommand.Begin), CastleProcessState.Active }, { new StateTransition(CastleProcessState.Active, CastleCommand.End), CastleProcessState.Inactive }, { new StateTransition(CastleProcessState.Active, CastleCommand.Pause), CastleProcessState.Paused }, { new StateTransition(CastleProcessState.Paused, CastleCommand.End), CastleProcessState.Inactive }, { new StateTransition(CastleProcessState.Paused, CastleCommand.Resume), CastleProcessState.Active } }; }
public CastleProcessState MoveNext(CastleCommand command) { CurrentState = GetNext(command); return(CurrentState); }
public StateTransition(CastleProcessState currentState, CastleCommand command) { CurrentState = currentState; Command = command; }