Ejemplo n.º 1
0
        public void Fire(TTrigger trigger)
        {
            if (!PermittedTriggers.Contains(trigger))
            {
                throw new NotSupportedException("'" + trigger + "' trigger is not configured for '" + CurrentState + "' state.");
            }

            TState oldState = CurrentState;
            TState newState = currentStateConfigs.GetTransitionState(trigger);
            IState <TState, TTrigger> oldStateRepresentation = GetStateConfigs(oldState);
            IState <TState, TTrigger> newStateRepresentation = GetStateConfigs(newState);

            if (e_OnUpdate != null)
            {
                e_OnUpdate();
            }

            IStateTransitions <TState, TTrigger> transition = new StateTransitions <TState, TTrigger>(oldState, newState, trigger);

            oldStateRepresentation.OnExit(transition);
            newStateRepresentation.OnEnter(transition);
            CurrentState = newState;
        }