use core::fmt::Debug;12use core::hash::Hash;34/// Types that can define world-wide states in a finite-state machine.5///6/// The [`Default`] trait defines the starting state.7/// Multiple states can be defined for the same world,8/// allowing you to classify the state of the world across orthogonal dimensions.9/// You can access the current state of type `T` with the [`State<T>`](crate::state::State) resource,10/// and the queued state with the [`NextState<T>`](crate::state::NextState) resource.11///12/// State transitions typically occur in the [`OnEnter<T::Variant>`](crate::state::OnEnter) and [`OnExit<T::Variant>`](crate::state::OnExit) schedules,13/// which can be run by triggering the [`StateTransition`](crate::state::StateTransition) schedule.14///15/// Types used as [`ComputedStates`](crate::state::ComputedStates) do not need to and should not derive [`States`].16/// [`ComputedStates`](crate::state::ComputedStates) should not be manually mutated: functionality provided17/// by the [`States`] derive and the associated [`FreelyMutableState`](crate::state::FreelyMutableState) trait.18///19/// # Example20///21/// ```22/// use bevy_state::prelude::*;23/// use bevy_ecs::prelude::IntoScheduleConfigs;24/// use bevy_ecs::system::{ResMut, ScheduleSystem};25///26///27/// #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]28/// enum GameState {29/// #[default]30/// MainMenu,31/// SettingsMenu,32/// InGame,33/// }34///35/// fn handle_escape_pressed(mut next_state: ResMut<NextState<GameState>>) {36/// # let escape_pressed = true;37/// if escape_pressed {38/// next_state.set(GameState::SettingsMenu);39/// }40/// }41///42/// fn open_settings_menu() {43/// // Show the settings menu...44/// }45///46/// # struct AppMock;47/// # impl AppMock {48/// # fn init_state<S>(&mut self) {}49/// # fn add_systems<S, M>(&mut self, schedule: S, systems: impl IntoScheduleConfigs<ScheduleSystem, M>) {}50/// # }51/// # struct Update;52/// # let mut app = AppMock;53///54/// app.init_state::<GameState>();55/// app.add_systems(Update, handle_escape_pressed.run_if(in_state(GameState::MainMenu)));56/// app.add_systems(OnEnter(GameState::SettingsMenu), open_settings_menu);57/// ```58#[diagnostic::on_unimplemented(59message = "`{Self}` can not be used as a state",60label = "invalid state",61note = "consider annotating `{Self}` with `#[derive(States)]`"62)]63pub trait States: 'static + Send + Sync + Clone + PartialEq + Eq + Hash + Debug {64/// How many other states this state depends on.65/// Used to help order transitions and de-duplicate [`ComputedStates`](crate::state::ComputedStates), as well as prevent cyclical66/// `ComputedState` dependencies.67const DEPENDENCY_DEPTH: usize = 1;68}697071