Пример #1
0
        public bool?SetState(BasicState nextState, bool forced = false)
        {
            if (nextState == currentState)
            {
                return(null);
            }

            if (forced || nextState.CanEnter())
            {
                failedState   = null;
                previousState = currentState;
                currentState  = nextState;

                if (previousState.OnExit != null)
                {
                    previousState.OnExit();
                }
                if (OnChange != null)
                {
                    OnChange(previousState.idx);
                }
                if (nextState.OnEnter != null)
                {
                    nextState.OnEnter();
                }
                return(true);
            }
            failedState = nextState;
            return(false);
        }
Пример #2
0
 public void RepeatEnter()
 {
     if (currentState.OnExit != null)
     {
         currentState.OnExit();
     }
     if (currentState.OnEnter != null)
     {
         currentState.OnEnter();
     }
 }