public void Update() { if (!Enable || WasShutdown) { return; } // Do transition to another state bool IsQueueStateDifferentThanCurrentState = (QueuedState != CurrentState); if (QueuedState != null && (IsQueueStateDifferentThanCurrentState || ForceStateChange)) { if (CurrentState != null && QueuedState != null) { CurrentState.Exit(this, QueuedStateID); } PreviousState = CurrentState; // Store prev state ... CurrentState = QueuedState; // Set to next state ... QueuedState = null; // Remove queued state ... CurrentState.Enter(this, PreviousStateID, Context); } // Queued state is current state ... else if (QueuedState == CurrentState) { QueuedState = null; } // Update current state ... if (CurrentState != null) { CurrentState.Update(this); } }
public void ChangeState(IFSMState <T> newState) { if (CurrentState != null) { CurrentState.Exit(Owner); } CurrentState = newState; if (CurrentState != null) { CurrentState.Enter(Owner); } }
/// <summary> /// Pops all stacked states, and sets the given state as the new state /// </summary> public void NewState(IFSMState newState) { while (_StateStack.Count > 0) { IFSMState state = _StateStack.Peek(); state.Exit(); _StateStack.Pop(); } _StateStack.Push(newState); newState.Enter(); }
public IEnumerator ChangeState(IFSMState newState) { StopAllCoroutines(); //Verifica se o estado atual nao é nulo if (currentState != null) { //Se nao for, damos um exit yield return(StartCoroutine(currentState.Exit())); } currentState = newState; StartCoroutine(currentState.Enter()); }
private void changeState(string newStateName) { if (currentState != null) { currentState.Exit(owner); } currentState = states[newStateName]; currentState.Enter(owner); if (OnStateChange != null) { OnStateChange(currentState.Name); } }
//--------------------------------------- // 상태 변경.. public void ChangeState(IFSMState <T> newState) { previousState = currentState; if (currentState != null) { currentState.Exit(owner); } currentState = newState; if (currentState != null) { currentState.Enter(owner); } } // public void ChangeState(IState<T> newState)
/// <summary> /// Pops the current state from the top of the stack and returns it. If there /// is another state left in the stack, it regains focus. /// </summary> /// <returns>The state popped from the stack, or NULL if the stack is empty</returns> public IFSMState PopState() { IFSMState returnState = null; if (_StateStack.Count > 0) { returnState = _StateStack.Peek(); returnState.Exit(); _StateStack.Pop(); if (_StateStack.Count > 0) { IFSMState newState = _StateStack.Peek(); newState.GainedFocus(); } } return(returnState); }
/// <summary> /// Changes the state. /// </summary> /// <param name="state">State.</param> public void ChangeState(IFSMState <T> state) { if (state == null) { return; } _autoChangeState = null; if (_currentState != state) { _previousState = _currentState; } if (_currentState != null) { _currentState.Exit(_stateEntity); } _currentState = state; _currentState.Enter(_stateEntity); }