protected void RemoveTranstion(FiniteStateTransition transition) { if (_allTransitions.Contains(transition)) { _allTransitions.Remove(transition); } }
protected void AddTransition <T1, T2>(string eventName) { string lastStateName = typeof(T1).Name; string nextStateName = typeof(T2).Name; FiniteStateTransition transition = new FiniteStateTransition(eventName, lastStateName, nextStateName); _allTransitions.Add(transition); }
// 根据事件名称,从状态迁移表中,取出下一个状态 private bool TryGetNextStateByEventName(string eventName, FiniteStateTransition transition, out FiniteState state) { state = null; if (!eventName.Equals(transition.EventName)) { return(false); } if (CurrentState == null || !CurrentState.Name.Equals(transition.LastStateName)) { return(false); } return(_allStates.TryGetValue(transition.NextStateName, out state)); }
private bool FindTransitionWithEventName(string eventName, out FiniteStateTransition transition) { transition = null; if (CurrentState == null) { return(false); } foreach (FiniteStateTransition trans in _allTransitions) { if (0 == eventName.CompareTo(trans.EventName) && 0 == CurrentState.Name.CompareTo(trans.LastStateName)) { transition = trans; return(true); } } return(false); }
protected void AddTransition(FiniteStateTransition transition) { _allTransitions.Add(transition); }