///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) { 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); }