public void Reset(State state_ = null) { try { state_ = state_ ?? Graph[0]; WhenTransit?.Invoke(-1, state_.Id, transitDepth); TransitTo(state_); } catch (Exception e) { Error(e); } }
private void Transit(State target_) { if (++transitDepth >= MaxTransitDepth) { Error(new Exception($"max fsm transit depth reached. current state = {CurrentState.Id}")); return; } WhenTransit?.Invoke(CurrentState.Id, target_.Id, transitDepth); try { //check/prevent transition in state exit CurrentState = null; ActingState.OnExit(this); TransitTo(target_); } catch (Exception e) { Error(e); } --transitDepth; }