///Enter a state providing the state itself public bool EnterState(FSMState newState) { if (!isRunning) { Debug.LogWarning("Tried to EnterState on an FSM that was not running", gameObject); return(false); } if (newState == null) { Debug.LogWarning("Tried to Enter Null State"); return(false); } if (currentState != null) { currentState.Finish(); currentState.ResetNode(); CallbackExit(currentState); //for editor.. foreach (Connection inConnection in currentState.inConnections) { inConnection.connectionStatus = Status.Resting; } /// } lastState = currentState; currentState = newState; currentState.Execute(agent, blackboard); CallbackEnter(currentState); return(true); }
///Enter a state providing the state itself public bool EnterState(FSMState newState, TransitionCallMode callMode) { if (!isRunning) { Logger.LogWarning("Tried to EnterState on an FSM that was not running", LogTag.EXECUTION, this); return(false); } if (newState == null) { Logger.LogWarning("Tried to Enter Null State", LogTag.EXECUTION, this); return(false); } if (currentState != null) { if (onStateExit != null) { onStateExit(currentState); } currentState.Reset(false); if (callMode == TransitionCallMode.Stacked) { stateStack.Push(currentState); if (stateStack.Count > 5) { Logger.LogWarning("State stack exceeds 5. Ensure that you are not cycling stack calls", LogTag.EXECUTION, this); } } } if (callMode == TransitionCallMode.Clean) { stateStack.Clear(); } previousState = currentState; currentState = newState; if (onStateTransition != null) { onStateTransition(currentState); } if (onStateEnter != null) { onStateEnter(currentState); } currentState.Execute(agent, blackboard); return(true); }
///Enter a state providing the state itself public bool EnterState(FSMState newState) { if (!isRunning) { Debug.LogWarning("Tried to EnterState on an FSM that was not running", this); return(false); } if (newState == null) { Debug.LogWarning("Tried to Enter Null State"); return(false); } if (currentState != null) { if (onStateExit != null) { onStateExit(currentState); } currentState.Finish(); currentState.Reset(); #if UNITY_EDITOR //Done for visualizing in editor for (var i = 0; i < currentState.inConnections.Count; i++) { currentState.inConnections[i].status = Status.Resting; } #endif } previousState = currentState; currentState = newState; if (onStateTransition != null) { onStateTransition(currentState); } if (onStateEnter != null) { onStateEnter(currentState); } currentState.Execute(agent, blackboard); return(true); }
///Enter a state providing the state itself public bool EnterState(FSMState newState) { if (!isRunning) { Debug.LogWarning("Tried to EnterState on an FSM that was not running", this); return(false); } if (newState == null) { Debug.LogWarning("Tried to Enter Null State"); return(false); } if (currentState == newState) { Debug.Log("Trying entering the same state"); return(false); } if (currentState != null) { currentState.Finish(); currentState.Reset(); if (CallbackExit != null) { CallbackExit(currentState); } //for editor.. foreach (var inConnection in currentState.inConnections) { inConnection.connectionStatus = Status.Resting; } /// } previousState = currentState; currentState = newState; currentState.Execute(agent, blackboard); if (CallbackEnter != null) { CallbackEnter(currentState); } return(true); }
///Enter a state providing the state itself public bool EnterState(FSMState newState) { if (!isRunning){ Debug.LogWarning("Tried to EnterState on an FSM that was not running", this); return false; } if (newState == null){ Debug.LogWarning("Tried to Enter Null State"); return false; } if (currentState != null){ if (CallbackExit != null){ CallbackExit(currentState); } currentState.Finish(); currentState.Reset(); #if UNITY_EDITOR //Done for visualizing in editor for (var i = 0; i < currentState.inConnections.Count; i++) currentState.inConnections[i].connectionStatus = Status.Resting; #endif } previousState = currentState; currentState = newState; if (CallbackEnter != null){ CallbackEnter(currentState); } currentState.Execute(agent, blackboard); return true; }
///Enter a state providing the state itself public bool EnterState(FSMState newState) { if (!isRunning){ Debug.LogWarning("Tried to EnterState on an FSM that was not running", this); return false; } if (newState == null){ Debug.LogWarning("Tried to Enter Null State"); return false; } /* if (currentState == newState){ Debug.Log("Trying entering the same state"); return false; } */ if (currentState != null){ currentState.Finish(); currentState.Reset(); if (CallbackExit != null) CallbackExit(currentState); //for editor.. foreach (var inConnection in currentState.inConnections) inConnection.connectionStatus = Status.Resting; /// } previousState = currentState; currentState = newState; currentState.Execute(agent, blackboard); if (CallbackEnter != null) CallbackEnter(currentState); return true; }