Skip to content

Commit

Permalink
Fix state machine entering and exiting states multiple times on each …
Browse files Browse the repository at this point in the history
…state change
  • Loading branch information
nightm4re94 committed Dec 8, 2024
1 parent 8a1d22b commit cb161b3
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public void update() {
List<Transition> transitions = currentState.getTransitions();
Collections.sort(transitions);
Optional<Transition> transition = transitions.stream().filter(Transition::conditionsFullfilled).findFirst();
if (transition.isPresent()) {
currentState.exit();
setState(transition.get().getNextState());
currentState.enter();
}
transition.ifPresent(value -> setState(value.getNextState()));
}
}

0 comments on commit cb161b3

Please sign in to comment.