public SimpleState AddState() { SimpleState newState = new SimpleState(); States.Add(newState); return(newState); }
public StateTransition(SimpleState from, SimpleState to) { _fromState = from; _toState = to; _onTransitionStart = new WriteAction(); _onTransitionEnd = new WriteAction(); OnTransitionStart = _onTransitionStart; OnTransitionEnd = _onTransitionEnd; }
public SimpleState AddState(SimpleState addedState) { if (States.Contains(addedState)) { return(addedState); } States.Add(addedState); return(addedState); }
public void RemoveTransition(SimpleState toState) { if (_activeTransition == toState) { EndTransition(); } if (_transitions.ContainsKey(toState)) { _transitions.Remove(toState); } }
public void AddTransition(SimpleState toState) { if (_transitions.ContainsKey(toState)) { StateTransition transition = _transitions[toState]; } else { _transitions.Add(toState, new StateTransition(this, toState)); } }
public new void EndTransition() { SimpleState newState = _activeState._activeTransition; if (newState == null) { return; } _activeState.EndTransition(); _activeState = newState; }
public ReadAction OnTransitionEnd(SimpleState toState) { StateTransition transition; if (_transitions.TryGetValue(toState, out transition)) { return(transition.OnTransitionEnd); } else { return(null); } }
protected void EndTransition() { if (_activeTransition == null) { return; } StateTransition transition; if (_transitions.TryGetValue(_activeTransition, out transition)) { transition.EndTransition(); } _activeTransition = null; }
protected void StartTransition(SimpleState to) { if (to == null) { return; } StateTransition transition; if (_transitions.TryGetValue(to, out transition)) { transition.StartTransition(); _activeTransition = to; } }
public new void StartTransition(SimpleState toState) { _activeState.StartTransition(toState); }
public void MoveState(SimpleState state, SimpleState.Machine toMachine) { States.Remove(state); toMachine.AddState(state); }
public void RemoveState(SimpleState state) { States.Remove(state); }
public Machine(SimpleState initial) : base() { _activeState = initial; OnStateEnter.Add(StateEntered); OnStateExit.Add(StateExited); }