public void AddTransition(iState from, iState to, Func <bool> predicate) { if (_transitions.TryGetValue(from.GetType(), out var transitions) == false) { transitions = new List <Transition>(); _transitions[from.GetType()] = transitions; } transitions.Add(new Transition(to, predicate)); }
public void SetState(iState state) { if (state == _CurrentState) { return; } _CurrentState?.OnExit(); _CurrentState = state; _transitions.TryGetValue(_CurrentState.GetType(), out _CurrentTransitions); if (_CurrentTransitions == null) { _CurrentTransitions = EmptyTransitions; } _CurrentState.OnEnter(); }