Exemple #1
0
    public bool ChangeState(FSMState <T> NewState, bool forceChange)
    {
        if (NewState == CurrentState && !forceChange)
        {
            return(false);
        }

#if DEBUG_STATES_ALL
        MessengerDebug.print("FSM(" + typeof(T) + "):Change State " + CurrentState + " to " + NewState);
#endif

        PreviousState = CurrentState;
        CurrentState  = NewState;

        if (PreviousState != null)
        {
            PreviousState.Exit(Owner);
        }

        if (CurrentState != null)
        {
            CurrentState.Enter(Owner);
        }

        return(true);
    }
Exemple #2
0
        private void HandleTransitionComplete(SkillFSMTransition transition)
        {
            CurrentTransition.OnComplete -= HandleTransitionComplete;

            PreviousState = CurrentState;
            CurrentState  = transition.ToState;

            CurrentTransition   = null;
            isInitialisingState = true;

            PreviousState.Exit();
            OnStateChange?.Invoke(PreviousState, CurrentState);

            CurrentState.Enter();
            OnStateEnter?.Invoke(CurrentState);

            isInitialisingState = false;
        }