public StateHierarchyBehaviourScheduler(IHierarchicalStateMachine <TState, TTrigger> stateMachine,
                                         StateHierarchy <TState, TTrigger> stateHierarchy,
                                         HierarchicalTransitionCollection <TState, TTrigger> transitions,
                                         HierarchicalTransitionValidator <TState, TTrigger> transitionValidator,
                                         IEqualityComparer <TState> stateComparer,
                                         IEqualityComparer <TTrigger> triggerComparer)
 {
     _stateMachine        = stateMachine;
     _stateHierarchy      = stateHierarchy;
     _transitions         = transitions;
     _transitionValidator = transitionValidator;
     _stateComparer       = stateComparer;
     _triggerComparer     = triggerComparer;
     _activeHierarchyPath = new List <KeyValuePair <TState, IState> >();
 }
Пример #2
0
        public HierarchicalStateMachine(IEqualityComparer <TState> stateComparer, IEqualityComparer <TTrigger> triggerComparer)
        {
            if (stateComparer == null)
            {
                throw new ArgumentNullException(nameof(stateComparer));
            }
            if (triggerComparer == null)
            {
                throw new ArgumentNullException(nameof(triggerComparer));
            }

            _stateComparer   = new StateEqualityComparer(stateComparer);
            _triggerComparer = new TriggerEqualityComparer(triggerComparer);

            _transitionComparer = new TransitionEqualityComparer <TState, TTrigger>(_stateComparer, _triggerComparer);

            _stateHierarchy = new StateHierarchy <TState, TTrigger>(this, _stateComparer);
            _stateHierarchyBehaviourScheduler = new StateHierarchyBehaviourScheduler <TState, TTrigger>(this, _stateHierarchy, _transitions, _transitionValidator, _stateComparer, _triggerComparer);
            _transitionValidator = new HierarchicalTransitionValidator <TState, TTrigger>(_stateComparer, _transitionComparer, _stateHierarchyBehaviourScheduler, _stateHierarchy);
            _transitions         = new HierarchicalTransitionCollection <TState, TTrigger>(this, _stateComparer, _transitionComparer);
            _eventHandlers       = new HierarchicalStateEventHandlerCollection <TState, TTrigger>(this, _stateComparer);
            _eventDispatcher     = new HierarchicalEventDispatcher <TState, TTrigger>(_stateComparer, _eventHandlers, _stateHierarchyBehaviourScheduler);
        }