public void FSMUpdate() { if (currentState == null) { return; } if (transformImmediately) { currentState.Exit(); currentState = nextState; currentState.Enter(); transformImmediately = false; } currentState.Excute(); if (currentState.Status == FSMSateStatus.Success) { currentState.Exit(); currentState = null; if (nextState != null) { currentState = nextState; currentState.Enter(); nextState = null; } else { currentState = defaultState; currentState.Enter(); } } }
public void ConfigState(T _stateOwner, FSMState <T> _currState, FSMState <T> _globalState) { stateOwner = _stateOwner; currState = _currState; globalState = _globalState; currState.Enter(_stateOwner); }
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); }
private void ApplyPendingChanges() { foreach (PendingChange change in pendingList) { switch (change.action) { case Action.Push: FSMState pushState = FindState(change.stateID); pushState.Enter(); stateStack.Push(pushState); break; case Action.Pop: FSMState popState = stateStack.Pop(); popState.Exit(); break; case Action.Clear: while (!IsEmpty()) { FSMState state = stateStack.Pop(); state.Exit(); } stateStack.Clear(); break; } } pendingList.Clear(); }
/// <summary> /// 改变状态 /// </summary> /// <param name="type"></param> public void ChangeState(FSMStateType type, params System.Object[] args) { if (CurrentType == FSMStateType.Dead) { return; } if (!map.ContainsKey(type)) { Debuger.LogError("不包含此状态" + type); } FSMState state = null; map.TryGetValue(type, out state); if (state == null) { Debuger.LogError("获取到的状态为空:" + type); return; } if (state == currentState) { return; } if (currentState != null) { currentState.Exit(); } currentState = state; currentType = type; currentState.Enter(args); }
private void SafePush(int stateID) { FSMState pushState = FindState(stateID); pushState.Enter(); stateStack.Push(pushState); }
void ChangeState(FSMState nextState) { ProcessUpdate = false; CurrentState.Leave(nextState); nextState.Enter(CurrentState); CurrentState = nextState; ProcessUpdate = true; }
public void Reset() { currentState = defaultState; if (currentState != null) { currentState.Enter(); } }
public void Update() { if (CurrentState.IsFinished) { CurrentState.Exit(); CurrentState = DefaultState; CurrentState.Enter(); } CurrentState.Execute(); }
public void ChangeState(FSMState <T> _newState) { if (currState != null && (_newState != currState)) { currState.Exit(stateOwner); preState = currState; currState = _newState; currState.Enter(stateOwner); } }
public void ChangeState(FSMState <T> newState) { if (currentState != null && !reverting) { previousStates.Push(currentState); } reverting = false; currentState?.Exit(owner); currentState = newState; currentState?.Enter(owner); }
public void Configure(T owner, FSMState <T> initialState, FSMState <T> globalState) { Owner = owner; if (globalState != null) { GlobalState = globalState; GlobalState.Enter(Owner); } ChangeState(initialState); }
public void ChangeState(FSMState <T> NewState) { PreviousState = CurrentState; if (PreviousState != null) { //Debug.Log(Owner + "EXITED STATE: " + PreviousState); PreviousState.Exit(); } //Debug.Log(Owner + "ENTERED STATE: " + NewState); CurrentState = NewState; CurrentState.Enter(Owner); }
public void ChangeState(FSMState <T> newState) { // NOTE: Right now, you can pass null to this. if (currentState != null) { currentState.Exit(); } currentState = newState; if (currentState != null) { currentState.Enter(owner); } }
public void SetGlobalState(string v) { if (globalState != null) { globalState.Exit(); } if (allStates.ContainsKey(v)) { globalState = allStates[v]; globalState.Enter(); } }
public void ChangeState(FSMState <T> nextState) { previousState = currentState; if (currentState != null) { currentState.Exit(owner); } currentState = nextState; if (currentState != null) { currentState.Enter(owner); } }
/// <summary> /// 处理下一个状态 /// </summary> /// <param name="cmd"></param> protected void ChangeState(ICmd cmd) { if (NextState == null) { return; } CurrentState.Release(); CurrentState.Exit(); CurrentState = NextState; CurrentState.Enter(cmd); NextState = null; }
public bool ChangeGlobalState(FSMState <T> NewGlobalState) { if (NewGlobalState != null) { GlobalState.Exit(Owner); NewGlobalState.Enter(Owner); GlobalState = NewGlobalState; return(true); } else { return(false); } }
public void Update() { FSMTransition transition = current.VerifyTransitions(); if (transition != null) { current.Exit(); transition.Fire(); current = current.NextState(transition); current.Enter(); } else { current.Stay(); } }
// Examine transitions leading out from the current state // If a condition is activated, change the current state and // take all the actions linked to: // 1. Exit from the current state // 2. The activated transition // 3. Enter to the new state // If no transition is activated, take the actions associated // to staying in the current state public void Update() // NOTE: this is NOT a MonoBehaviour { FSMTransition transition = current.VerifyTransitions(); if (transition != null) { current.Exit(); transition.Fire(); current = current.NextState(transition); current.Enter(); } else { current.Stay(); } }
public void ChangeState(FSMState <T, U> NewState) { mPreviousState = mCurrentState; if (mCurrentState != null) { mCurrentState.Exit(); } mCurrentState = NewState; if (mCurrentState != null) { mCurrentState.Enter(); } }
public void PerformTransition(Transition trans) { FSMState state = m_curState.GetState(trans); if (state != null) { Debug.Log("切换到状态 : " + trans.ToString()); m_curState.Exit(m_owner); m_curState = state; m_curState.Enter(m_owner); } else { Debug.LogError("转换到 " + trans.ToString() + " 失败"); } }
public void ChangeState(FSMState <T> newState) { _previousState = _currentState; if (_currentState != null) { _currentState.Exit(Owner); } _currentState = newState; if (_currentState != null) { _currentState.Enter(Owner); } }
//ステート切り替えメソッド //現在のステートの終了メソッドを行ってから、現在のステートを切り替える public void ChangeState(FSMState <T> NewState) { PreviousState = CurrentState; if (CurrentState != null) { CurrentState.Exit(Owner); } CurrentState = NewState; if (CurrentState != null) { CurrentState.Enter(Owner); } }
public void ChangeState(FSMState <T> newState) { if (CurrentState == newState || newState == null) { return; } if (CurrentState != null) { CurrentState.Exit(Owner); } LastState = CurrentState; CurrentState = newState; CurrentState.Enter(Owner); }
/// <summary> /// 通过命令跳转到相应状态 /// </summary> /// <param name="cmd"></param> /// <param name="args"></param> public void ExecuteCmd(string cmd, params object[] args) { FSMState toState = CurrentState.GetDestState(cmd); if(toState == null) { return; } else if(toState == CurrentState) { CurrentState.Enter(args); } else { CurrentState.Exit(); CurrentState = toState; CurrentState.Enter(args); } }
public void SwitchTo(int code) { if (null != curState && curState.Code == code) { return; } if (null != curState) { curState.Exit(); } curState = GetState(code); if (null != curState) { curState.Enter(); } }
public void ChangeState(FSMState <T, U> NewState) { PreviousState = CurrentState; if (PreviousState == NewState) { return; } if (CurrentState != null) { CurrentState.Exit(); } CurrentState = NewState; if (CurrentState != null) { CurrentState.Enter(); } }
public bool ChangeState(string id, object param = null) { if (id == null || !allStates.ContainsKey(id)) { //DebugUtil.Log("fsm: state not exist: " + id); return(false); } FSMState <T> newState = allStates[id]; if (newState == currentState) { // DebugUtil.Log("fsm: try to switch to same state " + id); return(true); } // currently changing to the target state. if (changingToState == id) { return(true); } changingToState = id; previousState = currentState; if (currentState != null) { currentState.Exit(); } currentState = newState; if (currentState != null) { currentState.SetParam(param); currentState.Enter(); } stackHistory.Add(id); changingToState = null; return(true); }
public void ChangeState(U newState) { _previousState = _currentState; if (_currentState != null) { _currentState.Exit(_owner); } if (_stateDictionary.ContainsKey(newState)) { _currentState = _stateDictionary[newState]; if (_currentState != null) { _currentState.Enter(_owner); } } else { Debug.LogError(newState.ToString() + " is not Registered."); } }
public void PerformTransition(GlobalStateData.FSMTransistion trans) { // Check for NullTransition before changing the current state if (trans == GlobalStateData.FSMTransistion.None) { Debug.LogError(SCRIPT_NAME + ": Null transition is not allowed"); return; } // Check if the currentState has the transition passed as argument GlobalStateData.FSMStateID id = currentState.GetOutputState(trans); if (id == GlobalStateData.FSMStateID.None) { Debug.LogError(SCRIPT_NAME + ": Current State does not have a target state for this transition"); return; } // Update the currentStateID and currentState //currentStateID = id; foreach (FSMState state in fsmStates) { if (state.ID == id) { // Store previous state and call exit method. previousState = currentState; previousState.Exit(); // Update current state and call enter method. currentState = state; currentState.Enter(); break; } } }
public void SwitchTo(int code) { if (null != curState && curState.Code == code) return; if (null != curState) { curState.Exit(); } curState = GetState(code); if (null != curState) { curState.Enter(); } }