public void SetState(AiState state) { if (currentState != null) { currentState.OnStateExit(); } currentState = state; if (currentState != null) { currentState.Init(); currentState.OnStateEnter(); } }
/// <summary> /// Send OnStateExit notification to previous state. /// </summary> private void NotifyOnStateExit() { previousState.OnStateExit(previousState, currentState); }