Skip to content

Commit

Permalink
Revert an unnecessary refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed May 14, 2024
1 parent b741797 commit 5ff2733
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/bevy_state/src/state/state_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ impl<S: InnerStateSet> StateSet for S {
}
parent_changed.clear();

let new_state = S::convert_to_usable_state(state_set.as_deref()).and_then(T::compute);
let new_state =
if let Some(state_set) = S::convert_to_usable_state(state_set.as_deref()) {
T::compute(state_set)
} else {
None
};

let same_state = current_state.as_ref().map(|x| x.get()) == new_state.as_ref();
if same_state && !should_refresh {
Expand Down Expand Up @@ -153,7 +158,12 @@ impl<S: InnerStateSet> StateSet for S {
}
parent_changed.clear();

let new_state = S::convert_to_usable_state(state_set.as_deref()).and_then(T::should_exist);
let new_state =
if let Some(state_set) = S::convert_to_usable_state(state_set.as_deref()) {
T::should_exist(state_set)
} else {
None
};

if current_state.is_none() || new_state.is_none() {
internal_apply_state_transition(event, commands, current_state, new_state);
Expand Down

0 comments on commit 5ff2733

Please sign in to comment.