private void UpdateState() { ProcessStateLeave(CurrentState.OnLeave); CurrentCoroutine?.Stop(); PreviousState = CurrentState; CurrentState = NextState; NextState = null; if (CurrentState == null) { return; } ProcessStateEnter(CurrentState.OnEnter); CurrentCoroutine = Coroutines.Instance.Start(ProcessStateUpdate(CurrentState.OnUpdate)); }
public void Stop() { if (!HasStarted) { return; } NextState = PreviousState = CurrentState = StartState = null; if (CurrentCoroutine != null) { Coroutines.Instance.Remove(CurrentCoroutine); CurrentCoroutine.Stop(); CurrentCoroutine = null; } HasStarted = IsRunning = false; }