public void Step() { if (!IsActive) { return; } using (ProfilingScope.Open(ActiveState)) { CurrentState.Run(StateStatus.Execute); TryChangingState(); } }
public void Step() { Debug.Assert(startState != null); if (activeState == null) { activeState = startState; activeState.StartState(); } using (ProfilingScope.Open(activeState)) { //Find the first triggered transition and consume it var transitions = activeState.Transitions; foreach (var transition in transitions) { if (!transition.IsUsable || !transition.HasTriggered) { continue; } var targetState = transition.TryConsumingTrigger(); if (targetState == null) { continue; } //Stop the last state, and start the next one activeState.StopState(); activeState = targetState; activeState.StartState(); break; } //Execute the current active state activeState.Execute(); } }