-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Objective - Make it possible to react to arbitrary state changes - this will be useful regardless of the other changes to states currently being discussed ## Solution - added `StateTransitionEvent<S>` struct - previously, this would have been impossible: ```rs #[derive(States, Eq, PartialEq, Hash, Copy, Clone, Default)] enum MyState { #[default] Foo, Bar(MySubState), } enum MySubState { Spam, Eggs, } app.add_system(Update, on_enter_bar); fn on_enter_bar(trans: EventReader<StateTransition<MyState>>){ for (befoare, after) in trans.read() { match before, after { MyState::Foo, MyState::Bar(_) => info!("detected transition foo => bar"); _, _ => (); } } } ``` --- ## Changelog - Added - `StateTransitionEvent<S>` - Fired on state changes of `S` ## Migration Guide N/A no breaking changes --------- Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
- Loading branch information
1 parent
8d9a0a8
commit 1260b7b
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters