public void AddTransition(IState from, IState to, Func <bool> condition) { if (_stateTransitions.ContainsKey(from) == false) { _stateTransitions[from] = new List <StateTransition>(); } StateTransition stateTransition = new StateTransition(from, to, condition); _stateTransitions[from].Add(stateTransition); }
public void Tick() { StateTransition transition = CheckForTransition(); if (transition != null) { SetState(transition.To); } CurrentState.Tick(); }
public void AddAnyTransition(IState to, Func <bool> condition) { StateTransition stateTransition = new StateTransition(null, to, condition); _anyStateTransitions.Add(stateTransition); }