public void SetStartState(TEnum startStateId)
        {
            BState <TEnum> startState = this.StateFromId(startStateId);

            _currentState         = startState;
            _remainingTimeInState = _currentState.GenerateTime();
        }
        // PRAGMA MARK - INTERFACE
        public void AddTransition(TEnum stateIdFrom, TEnum stateIdTo, int weight)
        {
            BState <TEnum> stateFrom = this.StateFromId(stateIdFrom);
            BState <TEnum> stateTo   = this.StateFromId(stateIdTo);

            BStateTransition <TEnum> newTransition = new BStateTransition <TEnum>(stateTo, weight);

            stateFrom.AddTransition(newTransition);
        }
        protected void TransitionToState(BState <TEnum> nextState)
        {
            if (nextState == null)
            {
                Debug.LogError("BasicFiniteStateMachine::TransitionToState - called with invalid state!");
                return;
            }

            // Delegate handling
            this.CallActionForMethod(_currentState.ExitKey());
            this.CallActionForMethod(_currentState.TransitionToNextStateKey(nextState));
            this.CallActionForMethod(nextState.EnterKey());

            _currentState         = nextState;
            _remainingTimeInState = _currentState.GenerateTime();
        }
        protected void InitializeState(BState <TEnum> state, TEnum[] allEnumValues)
        {
            foreach (TEnum e in allEnumValues)
            {
                if (state.Id.Equals(e))
                {
                    continue;
                }

                this.SetupActionForMethod(state.TransitionToNextStateIdKey(e));
            }

            this.SetupActionForMethod(state.EnterKey());
            this.SetupActionForMethod(state.TickKey());
            this.SetupActionForMethod(state.FixedTickKey());
            this.SetupActionForMethod(state.ExitKey());
        }
        protected virtual void Awake()
        {
            if (!typeof(TEnum).IsEnum)
            {
                Debug.LogError("BasicFiniteStateMachine::() - TEnum generic constraint not satisfied!");
            }

            _stateHash        = new Dictionary <TEnum, BState <TEnum> >();
            _stateActionCache = new Dictionary <string, Action>();

            // cache all of our state methods
            TEnum[] enumValues = (TEnum[])Enum.GetValues(typeof(TEnum));
            foreach (TEnum e in enumValues)
            {
                BState <TEnum> state = new BState <TEnum>(e);
                _stateHash.Add(state.Id, state);
                this.InitializeState(state, enumValues);
            }

            _remainingTimeInState = 0.0f;

            this.SetupStateMachine();
        }
 // PRAGMA MARK - INTERFACE
 public string TransitionToNextStateKey(BState <TEnum> stateNext)
 {
     return(this.TransitionToNextStateIdKey(stateNext.Id));
 }
        public void ForceTransitionToStateEnum(TEnum stateId)
        {
            BState <TEnum> state = this.StateFromId(stateId);

            this.TransitionToState(state);
        }
        public void AdvanceCurrentState()
        {
            BState <TEnum> nextState = _currentState.ChooseNextState();

            this.TransitionToState(nextState);
        }
        public void SetMinMaxTime(TEnum stateId, float min, float max)
        {
            BState <TEnum> state = this.StateFromId(stateId);

            state.SetMinMaxTime(min, max);
        }
 public BStateTransition(BState <TEnum> destinationState, int weight)
 {
     _destinationState = destinationState;
     _weight           = weight;
 }