impl Default for StateScoped<S: Default> (#17401)
This allows this: ```rust #[derive(Component)] #[require(StateScoped<MyState>(StateScoped(MyState)))] struct ComponentA; ``` To be shortened to this: ```rust #[derive(Component)] #[require(StateScoped<MyState>)] struct ComponentA; ``` When `MyState` implements `Default`. Signed-off-by: Jean Mertz <git@jeanmertz.com>
This commit is contained in:
parent
14a955c5eb
commit
23dbcf9215
@ -60,6 +60,15 @@ use crate::state::{StateTransitionEvent, States};
|
|||||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Component))]
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Component))]
|
||||||
pub struct StateScoped<S: States>(pub S);
|
pub struct StateScoped<S: States>(pub S);
|
||||||
|
|
||||||
|
impl<S> Default for StateScoped<S>
|
||||||
|
where
|
||||||
|
S: States + Default,
|
||||||
|
{
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(S::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Removes entities marked with [`StateScoped<S>`]
|
/// Removes entities marked with [`StateScoped<S>`]
|
||||||
/// when their state no longer matches the world state.
|
/// when their state no longer matches the world state.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user