public void RegisterTransition(int state, int command, int finishState, TransitionActionCallback action) { if (state < 0 || command < 0 || finishState < 0) { return; } StateTransition transition = new StateTransition(state, command, finishState, action, SetState); if (_transitions.ContainsKey(transition.GetID())) { Log.Error(MessageGroup.Common, "Given transition is already registered in state machine named : " + Name); return; } _transitions[transition.GetID()] = transition; }
public void Switch(int command) { if (_currentState == -1) { return; } if (command < 0) { Log.Error(MessageGroup.Common, "Given command is smaller than zero in state machine named : " + Name); return; } var transitionID = StateTransition.GenerateID(_currentState, command); if (!_transitions.ContainsKey(transitionID)) { return; } _transitions[transitionID].MakeTransition(); }