///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; }
public GUIPort(FSMState parent, Vector2 pos) { this.parent = parent; this.pos = pos; }
protected override void OnGraphPaused() { lastState = currentState; }
protected override void OnGraphStoped() { lastState = null; currentState = null; }
protected override void OnGraphPaused() { previousState = currentState; currentState = null; }
protected override void OnGraphStoped() { previousState = null; currentState = null; }
///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; }