Skip to main content

NextState

Enum NextState 

Source
pub enum NextState<S>{
    Unchanged,
    Pending(S),
    PendingIfNeq(S),
}
Expand description

The next state of State<S>.

This can be fetched as a resource and used to queue state transitions. To queue a transition, call NextState::set or mutate the value to NextState::Pending directly.

Note that these transitions can be overridden by other systems: only the actual value of this resource during the StateTransition schedule matters.

use bevy_state::prelude::*;
use bevy_ecs::prelude::*;

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]
enum GameState {
    #[default]
    MainMenu,
    SettingsMenu,
    InGame,
}

fn start_game(mut next_game_state: ResMut<NextState<GameState>>) {
    next_game_state.set(GameState::InGame);
}

Variants§

§

Unchanged

No state transition is pending

§

Pending(S)

There is a pending transition for state S

§

PendingIfNeq(S)

There is a pending transition for state S

This will not trigger state transitions schedules if the target state is the same as the current one.

Implementations§

Source§

impl<S> NextState<S>

Source

pub fn set(&mut self, state: S)

Tentatively set a pending state transition to Some(state).

This will run the state transition schedules OnEnter and OnExit. If you want to skip those schedules for the same where we are transitioning to the same state, use set_if_neq instead.

Examples found in repository?
examples/ecs/generic_system.rs (line 79)
74fn transition_to_in_game_system(
75    mut next_state: ResMut<NextState<AppState>>,
76    keyboard_input: Res<ButtonInput<KeyCode>>,
77) {
78    if keyboard_input.pressed(KeyCode::Space) {
79        next_state.set(AppState::InGame);
80    }
81}
More examples
Hide additional examples
examples/showcase/game_menu.rs (line 108)
102    fn countdown(
103        mut game_state: ResMut<NextState<GameState>>,
104        time: Res<Time>,
105        mut timer: ResMut<SplashTimer>,
106    ) {
107        if timer.tick(time.delta()).is_finished() {
108            game_state.set(GameState::Menu);
109        }
110    }
111}
112
113mod game {
114    use bevy::{
115        color::palettes::basic::{BLUE, LIME},
116        prelude::*,
117    };
118
119    use super::{DisplayQuality, GameState, Volume, TEXT_COLOR};
120
121    // This plugin will contain the game. In this case, it's just be a screen that will
122    // display the current settings for 5 seconds before returning to the menu
123    pub fn game_plugin(app: &mut App) {
124        app.add_systems(OnEnter(GameState::Game), game_setup)
125            .add_systems(Update, game.run_if(in_state(GameState::Game)));
126    }
127
128    // Tag component used to tag entities added on the game screen
129    #[derive(Component)]
130    struct OnGameScreen;
131
132    #[derive(Resource, Deref, DerefMut)]
133    struct GameTimer(Timer);
134
135    fn game_setup(
136        mut commands: Commands,
137        display_quality: Res<DisplayQuality>,
138        volume: Res<Volume>,
139    ) {
140        commands.spawn((
141            DespawnOnExit(GameState::Game),
142            Node {
143                width: percent(100),
144                height: percent(100),
145                // center children
146                align_items: AlignItems::Center,
147                justify_content: JustifyContent::Center,
148                ..default()
149            },
150            OnGameScreen,
151            children![(
152                Node {
153                    // This will display its children in a column, from top to bottom
154                    flex_direction: FlexDirection::Column,
155                    // `align_items` will align children on the cross axis. Here the main axis is
156                    // vertical (column), so the cross axis is horizontal. This will center the
157                    // children
158                    align_items: AlignItems::Center,
159                    ..default()
160                },
161                BackgroundColor(Color::BLACK),
162                children![
163                    (
164                        Text::new("Will be back to the menu shortly..."),
165                        TextFont {
166                            font_size: FontSize::Px(67.0),
167                            ..default()
168                        },
169                        TextColor(TEXT_COLOR),
170                        Node {
171                            margin: UiRect::all(px(50)),
172                            ..default()
173                        },
174                    ),
175                    (
176                        Text::default(),
177                        Node {
178                            margin: UiRect::all(px(50)),
179                            ..default()
180                        },
181                        children![
182                            (
183                                TextSpan(format!("quality: {:?}", *display_quality)),
184                                TextFont {
185                                    font_size: FontSize::Px(50.0),
186                                    ..default()
187                                },
188                                TextColor(BLUE.into()),
189                            ),
190                            (
191                                TextSpan::new(" - "),
192                                TextFont {
193                                    font_size: FontSize::Px(50.0),
194                                    ..default()
195                                },
196                                TextColor(TEXT_COLOR),
197                            ),
198                            (
199                                TextSpan(format!("volume: {:?}", *volume)),
200                                TextFont {
201                                    font_size: FontSize::Px(50.0),
202                                    ..default()
203                                },
204                                TextColor(LIME.into()),
205                            ),
206                        ]
207                    ),
208                ]
209            )],
210        ));
211        // Spawn a 5 seconds timer to trigger going back to the menu
212        commands.insert_resource(GameTimer(Timer::from_seconds(5.0, TimerMode::Once)));
213    }
214
215    // Tick the timer, and change state when finished
216    fn game(
217        time: Res<Time>,
218        mut game_state: ResMut<NextState<GameState>>,
219        mut timer: ResMut<GameTimer>,
220    ) {
221        if timer.tick(time.delta()).is_finished() {
222            game_state.set(GameState::Menu);
223        }
224    }
225}
226
227mod menu {
228    use bevy::{
229        app::AppExit,
230        color::palettes::css::CRIMSON,
231        ecs::component::Mutable,
232        ecs::spawn::{SpawnIter, SpawnWith},
233        prelude::*,
234    };
235
236    use super::{DisplayQuality, GameState, Setting, Volume, TEXT_COLOR};
237
238    // This plugin manages the menu, with 5 different screens:
239    // - a main menu with "New Game", "Settings", "Quit"
240    // - a settings menu with two submenus and a back button
241    // - two settings screen with a setting that can be set and a back button
242    pub fn menu_plugin(app: &mut App) {
243        app
244            // At start, the menu is not enabled. This will be changed in `menu_setup` when
245            // entering the `GameState::Menu` state.
246            // Current screen in the menu is handled by an independent state from `GameState`
247            .init_state::<MenuState>()
248            .add_systems(OnEnter(GameState::Menu), menu_setup)
249            // Systems to handle the main menu screen
250            .add_systems(OnEnter(MenuState::Main), main_menu_setup)
251            // Systems to handle the settings menu screen
252            .add_systems(OnEnter(MenuState::Settings), settings_menu_setup)
253            // Systems to handle the display settings screen
254            .add_systems(
255                OnEnter(MenuState::SettingsDisplay),
256                display_settings_menu_setup,
257            )
258            .add_systems(
259                Update,
260                (setting_button::<DisplayQuality>.run_if(in_state(MenuState::SettingsDisplay)),),
261            )
262            // Systems to handle the sound settings screen
263            .add_systems(OnEnter(MenuState::SettingsSound), sound_settings_menu_setup)
264            .add_systems(
265                Update,
266                setting_button::<Volume>.run_if(in_state(MenuState::SettingsSound)),
267            )
268            // Common systems to all screens that handles buttons behavior
269            .add_systems(
270                Update,
271                (menu_action, button_system).run_if(in_state(GameState::Menu)),
272            );
273    }
274
275    // State used for the current menu screen
276    #[derive(Clone, Copy, Default, Eq, PartialEq, Debug, Hash, States)]
277    enum MenuState {
278        Main,
279        Settings,
280        SettingsDisplay,
281        SettingsSound,
282        #[default]
283        Disabled,
284    }
285
286    // Tag component used to tag entities added on the main menu screen
287    #[derive(Component)]
288    struct OnMainMenuScreen;
289
290    // Tag component used to tag entities added on the settings menu screen
291    #[derive(Component)]
292    struct OnSettingsMenuScreen;
293
294    // Tag component used to tag entities added on the display settings menu screen
295    #[derive(Component)]
296    struct OnDisplaySettingsMenuScreen;
297
298    // Tag component used to tag entities added on the sound settings menu screen
299    #[derive(Component)]
300    struct OnSoundSettingsMenuScreen;
301
302    const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15);
303    const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25);
304    const HOVERED_PRESSED_BUTTON: Color = Color::srgb(0.25, 0.65, 0.25);
305    const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35);
306
307    // Tag component used to mark which setting is currently selected
308    #[derive(Component)]
309    struct SelectedOption;
310
311    // All actions that can be triggered from a button click
312    #[derive(Component)]
313    enum MenuButtonAction {
314        Play,
315        Settings,
316        SettingsDisplay,
317        SettingsSound,
318        BackToMainMenu,
319        BackToSettings,
320        Quit,
321    }
322
323    // This system handles changing all buttons color based on mouse interaction
324    fn button_system(
325        mut interaction_query: Query<
326            (&Interaction, &mut BackgroundColor, Option<&SelectedOption>),
327            (Changed<Interaction>, With<Button>),
328        >,
329    ) {
330        for (interaction, mut background_color, selected) in &mut interaction_query {
331            *background_color = match (*interaction, selected) {
332                (Interaction::Pressed, _) | (Interaction::None, Some(_)) => PRESSED_BUTTON.into(),
333                (Interaction::Hovered, Some(_)) => HOVERED_PRESSED_BUTTON.into(),
334                (Interaction::Hovered, None) => HOVERED_BUTTON.into(),
335                (Interaction::None, None) => NORMAL_BUTTON.into(),
336            }
337        }
338    }
339
340    // This system updates the settings when a new value for a setting is selected, and marks
341    // the button as the one currently selected
342    fn setting_button<T: Resource<Mutability = Mutable> + Component + PartialEq + Copy>(
343        interaction_query: Query<
344            (&Interaction, &Setting<T>, Entity),
345            (Changed<Interaction>, With<Button>),
346        >,
347        selected_query: Single<(Entity, &mut BackgroundColor), With<SelectedOption>>,
348        mut commands: Commands,
349        mut setting: ResMut<T>,
350    ) {
351        let (previous_button, mut previous_button_color) = selected_query.into_inner();
352        for (interaction, button_setting, entity) in &interaction_query {
353            if *interaction == Interaction::Pressed && *setting != button_setting.0 {
354                *previous_button_color = NORMAL_BUTTON.into();
355                commands.entity(previous_button).remove::<SelectedOption>();
356                commands.entity(entity).insert(SelectedOption);
357                *setting = button_setting.0;
358            }
359        }
360    }
361
362    fn menu_setup(mut menu_state: ResMut<NextState<MenuState>>) {
363        menu_state.set(MenuState::Main);
364    }
365
366    fn main_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
367        // Common style for all buttons on the screen
368        let button_node = Node {
369            width: px(300),
370            height: px(65),
371            margin: UiRect::all(px(20)),
372            justify_content: JustifyContent::Center,
373            align_items: AlignItems::Center,
374            ..default()
375        };
376        let button_icon_node = Node {
377            width: px(30),
378            // This takes the icons out of the flexbox flow, to be positioned exactly
379            position_type: PositionType::Absolute,
380            // The icon will be close to the left border of the button
381            left: px(10),
382            ..default()
383        };
384        let button_text_font = TextFont {
385            font_size: FontSize::Px(33.0),
386            ..default()
387        };
388
389        let right_icon = asset_server.load("textures/Game Icons/right.png");
390        let wrench_icon = asset_server.load("textures/Game Icons/wrench.png");
391        let exit_icon = asset_server.load("textures/Game Icons/exitRight.png");
392
393        commands.spawn((
394            DespawnOnExit(MenuState::Main),
395            Node {
396                width: percent(100),
397                height: percent(100),
398                align_items: AlignItems::Center,
399                justify_content: JustifyContent::Center,
400                ..default()
401            },
402            OnMainMenuScreen,
403            children![(
404                Node {
405                    flex_direction: FlexDirection::Column,
406                    align_items: AlignItems::Center,
407                    ..default()
408                },
409                BackgroundColor(CRIMSON.into()),
410                children![
411                    // Display the game name
412                    (
413                        Text::new("Bevy Game Menu UI"),
414                        TextFont {
415                            font_size: FontSize::Px(67.0),
416                            ..default()
417                        },
418                        TextColor(TEXT_COLOR),
419                        Node {
420                            margin: UiRect::all(px(50)),
421                            ..default()
422                        },
423                    ),
424                    // Display three buttons for each action available from the main menu:
425                    // - new game
426                    // - settings
427                    // - quit
428                    (
429                        Button,
430                        button_node.clone(),
431                        BackgroundColor(NORMAL_BUTTON),
432                        MenuButtonAction::Play,
433                        children![
434                            (ImageNode::new(right_icon), button_icon_node.clone()),
435                            (
436                                Text::new("New Game"),
437                                button_text_font.clone(),
438                                TextColor(TEXT_COLOR),
439                            ),
440                        ]
441                    ),
442                    (
443                        Button,
444                        button_node.clone(),
445                        BackgroundColor(NORMAL_BUTTON),
446                        MenuButtonAction::Settings,
447                        children![
448                            (ImageNode::new(wrench_icon), button_icon_node.clone()),
449                            (
450                                Text::new("Settings"),
451                                button_text_font.clone(),
452                                TextColor(TEXT_COLOR),
453                            ),
454                        ]
455                    ),
456                    (
457                        Button,
458                        button_node,
459                        BackgroundColor(NORMAL_BUTTON),
460                        MenuButtonAction::Quit,
461                        children![
462                            (ImageNode::new(exit_icon), button_icon_node),
463                            (Text::new("Quit"), button_text_font, TextColor(TEXT_COLOR),),
464                        ]
465                    ),
466                ]
467            )],
468        ));
469    }
470
471    fn settings_menu_setup(mut commands: Commands) {
472        let button_node = Node {
473            width: px(200),
474            height: px(65),
475            margin: UiRect::all(px(20)),
476            justify_content: JustifyContent::Center,
477            align_items: AlignItems::Center,
478            ..default()
479        };
480
481        let button_text_style = (
482            TextFont {
483                font_size: FontSize::Px(33.0),
484                ..default()
485            },
486            TextColor(TEXT_COLOR),
487        );
488
489        commands.spawn((
490            DespawnOnExit(MenuState::Settings),
491            Node {
492                width: percent(100),
493                height: percent(100),
494                align_items: AlignItems::Center,
495                justify_content: JustifyContent::Center,
496                ..default()
497            },
498            OnSettingsMenuScreen,
499            children![(
500                Node {
501                    flex_direction: FlexDirection::Column,
502                    align_items: AlignItems::Center,
503                    ..default()
504                },
505                BackgroundColor(CRIMSON.into()),
506                Children::spawn(SpawnIter(
507                    [
508                        (MenuButtonAction::SettingsDisplay, "Display"),
509                        (MenuButtonAction::SettingsSound, "Sound"),
510                        (MenuButtonAction::BackToMainMenu, "Back"),
511                    ]
512                    .into_iter()
513                    .map(move |(action, text)| {
514                        (
515                            Button,
516                            button_node.clone(),
517                            BackgroundColor(NORMAL_BUTTON),
518                            action,
519                            children![(Text::new(text), button_text_style.clone())],
520                        )
521                    })
522                ))
523            )],
524        ));
525    }
526
527    fn display_settings_menu_setup(mut commands: Commands, display_quality: Res<DisplayQuality>) {
528        fn button_node() -> Node {
529            Node {
530                width: px(200),
531                height: px(65),
532                margin: UiRect::all(px(20)),
533                justify_content: JustifyContent::Center,
534                align_items: AlignItems::Center,
535                ..default()
536            }
537        }
538        fn button_text_style() -> impl Bundle {
539            (
540                TextFont {
541                    font_size: FontSize::Px(33.0),
542                    ..default()
543                },
544                TextColor(TEXT_COLOR),
545            )
546        }
547
548        let display_quality = *display_quality;
549        commands.spawn((
550            DespawnOnExit(MenuState::SettingsDisplay),
551            Node {
552                width: percent(100),
553                height: percent(100),
554                align_items: AlignItems::Center,
555                justify_content: JustifyContent::Center,
556                ..default()
557            },
558            OnDisplaySettingsMenuScreen,
559            children![(
560                Node {
561                    flex_direction: FlexDirection::Column,
562                    align_items: AlignItems::Center,
563                    ..default()
564                },
565                BackgroundColor(CRIMSON.into()),
566                children![
567                    // Create a new `Node`, this time not setting its `flex_direction`. It will
568                    // use the default value, `FlexDirection::Row`, from left to right.
569                    (
570                        Node {
571                            align_items: AlignItems::Center,
572                            ..default()
573                        },
574                        BackgroundColor(CRIMSON.into()),
575                        Children::spawn((
576                            // Display a label for the current setting
577                            Spawn((Text::new("Display Quality"), button_text_style())),
578                            SpawnWith(move |parent: &mut ChildSpawner| {
579                                for quality_setting in [
580                                    DisplayQuality::Low,
581                                    DisplayQuality::Medium,
582                                    DisplayQuality::High,
583                                ] {
584                                    let mut entity = parent.spawn((
585                                        Button,
586                                        Node {
587                                            width: px(150),
588                                            height: px(65),
589                                            ..button_node()
590                                        },
591                                        BackgroundColor(NORMAL_BUTTON),
592                                        Setting(quality_setting),
593                                        children![(
594                                            Text::new(format!("{quality_setting:?}")),
595                                            button_text_style(),
596                                        )],
597                                    ));
598                                    if display_quality == quality_setting {
599                                        entity.insert(SelectedOption);
600                                    }
601                                }
602                            })
603                        ))
604                    ),
605                    // Display the back button to return to the settings screen
606                    (
607                        Button,
608                        button_node(),
609                        BackgroundColor(NORMAL_BUTTON),
610                        MenuButtonAction::BackToSettings,
611                        children![(Text::new("Back"), button_text_style())]
612                    )
613                ]
614            )],
615        ));
616    }
617
618    fn sound_settings_menu_setup(mut commands: Commands, volume: Res<Volume>) {
619        let button_node = Node {
620            width: px(200),
621            height: px(65),
622            margin: UiRect::all(px(20)),
623            justify_content: JustifyContent::Center,
624            align_items: AlignItems::Center,
625            ..default()
626        };
627        let button_text_style = (
628            TextFont {
629                font_size: FontSize::Px(33.0),
630                ..default()
631            },
632            TextColor(TEXT_COLOR),
633        );
634
635        let volume = *volume;
636        let button_node_clone = button_node.clone();
637        commands.spawn((
638            DespawnOnExit(MenuState::SettingsSound),
639            Node {
640                width: percent(100),
641                height: percent(100),
642                align_items: AlignItems::Center,
643                justify_content: JustifyContent::Center,
644                ..default()
645            },
646            OnSoundSettingsMenuScreen,
647            children![(
648                Node {
649                    flex_direction: FlexDirection::Column,
650                    align_items: AlignItems::Center,
651                    ..default()
652                },
653                BackgroundColor(CRIMSON.into()),
654                children![
655                    (
656                        Node {
657                            align_items: AlignItems::Center,
658                            ..default()
659                        },
660                        BackgroundColor(CRIMSON.into()),
661                        Children::spawn((
662                            Spawn((Text::new("Volume"), button_text_style.clone())),
663                            SpawnWith(move |parent: &mut ChildSpawner| {
664                                for volume_setting in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {
665                                    let mut entity = parent.spawn((
666                                        Button,
667                                        Node {
668                                            width: px(30),
669                                            height: px(65),
670                                            ..button_node_clone.clone()
671                                        },
672                                        BackgroundColor(NORMAL_BUTTON),
673                                        Setting(Volume(volume_setting)),
674                                    ));
675                                    if volume == Volume(volume_setting) {
676                                        entity.insert(SelectedOption);
677                                    }
678                                }
679                            })
680                        ))
681                    ),
682                    (
683                        Button,
684                        button_node,
685                        BackgroundColor(NORMAL_BUTTON),
686                        MenuButtonAction::BackToSettings,
687                        children![(Text::new("Back"), button_text_style)]
688                    )
689                ]
690            )],
691        ));
692    }
693
694    fn menu_action(
695        interaction_query: Query<
696            (&Interaction, &MenuButtonAction),
697            (Changed<Interaction>, With<Button>),
698        >,
699        mut app_exit_writer: MessageWriter<AppExit>,
700        mut menu_state: ResMut<NextState<MenuState>>,
701        mut game_state: ResMut<NextState<GameState>>,
702    ) {
703        for (interaction, menu_button_action) in &interaction_query {
704            if *interaction == Interaction::Pressed {
705                match menu_button_action {
706                    MenuButtonAction::Quit => {
707                        app_exit_writer.write(AppExit::Success);
708                    }
709                    MenuButtonAction::Play => {
710                        game_state.set(GameState::Game);
711                        menu_state.set(MenuState::Disabled);
712                    }
713                    MenuButtonAction::Settings => menu_state.set(MenuState::Settings),
714                    MenuButtonAction::SettingsDisplay => {
715                        menu_state.set(MenuState::SettingsDisplay);
716                    }
717                    MenuButtonAction::SettingsSound => {
718                        menu_state.set(MenuState::SettingsSound);
719                    }
720                    MenuButtonAction::BackToMainMenu => menu_state.set(MenuState::Main),
721                    MenuButtonAction::BackToSettings => {
722                        menu_state.set(MenuState::Settings);
723                    }
724                }
725            }
726        }
727    }
examples/testbed/2d.rs (line 103)
96fn switch_scene(
97    keyboard: Res<ButtonInput<KeyCode>>,
98    scene: Res<State<Scene>>,
99    mut next_scene: ResMut<NextState<Scene>>,
100) {
101    if keyboard.just_pressed(KeyCode::Space) {
102        info!("Switching scene");
103        next_scene.set(scene.get().next());
104    }
105}
examples/testbed/3d.rs (line 115)
108fn switch_scene(
109    keyboard: Res<ButtonInput<KeyCode>>,
110    scene: Res<State<Scene>>,
111    mut next_scene: ResMut<NextState<Scene>>,
112) {
113    if keyboard.just_pressed(KeyCode::Space) {
114        info!("Switching scene");
115        next_scene.set(scene.get().next());
116    }
117}
examples/testbed/ui.rs (line 145)
138fn switch_scene(
139    keyboard: Res<ButtonInput<KeyCode>>,
140    scene: Res<State<Scene>>,
141    mut next_scene: ResMut<NextState<Scene>>,
142) {
143    if keyboard.just_pressed(KeyCode::Space) {
144        info!("Switching scene");
145        next_scene.set(scene.get().next());
146    }
147}
examples/math/render_primitives.rs (line 362)
357fn switch_cameras(current: Res<State<CameraActive>>, mut next: ResMut<NextState<CameraActive>>) {
358    let next_state = match current.get() {
359        CameraActive::Dim2 => CameraActive::Dim3,
360        CameraActive::Dim3 => CameraActive::Dim2,
361    };
362    next.set(next_state);
363}
364
365fn setup_text(mut commands: Commands, cameras: Query<(Entity, &Camera)>) {
366    let active_camera = cameras
367        .iter()
368        .find_map(|(entity, camera)| camera.is_active.then_some(entity))
369        .expect("run condition ensures existence");
370    commands.spawn((
371        HeaderNode,
372        Node {
373            justify_self: JustifySelf::Center,
374            top: px(5),
375            ..Default::default()
376        },
377        UiTargetCamera(active_camera),
378        children![(
379            Text::default(),
380            HeaderText,
381            TextLayout::justify(Justify::Center),
382            children![
383                TextSpan::new("Primitive: "),
384                TextSpan(format!("{text}", text = PrimitiveSelected::default())),
385                TextSpan::new("\n\n"),
386                TextSpan::new(
387                    "Press 'C' to switch between 2D and 3D mode\n\
388                    Press 'Up' or 'Down' to switch to the next/previous primitive",
389                ),
390                TextSpan::new("\n\n"),
391                TextSpan::new("(If nothing is displayed, there's no rendering support yet)",),
392            ]
393        )],
394    ));
395}
396
397fn update_text(
398    primitive_state: Res<State<PrimitiveSelected>>,
399    header: Query<Entity, With<HeaderText>>,
400    mut writer: TextUiWriter,
401) {
402    let new_text = format!("{text}", text = primitive_state.get());
403    header.iter().for_each(|header_text| {
404        if let Some(mut text) = writer.get_text(header_text, 2) {
405            (*text).clone_from(&new_text);
406        };
407    });
408}
409
410fn switch_to_next_primitive(
411    current: Res<State<PrimitiveSelected>>,
412    mut next: ResMut<NextState<PrimitiveSelected>>,
413) {
414    let next_state = current.get().next();
415    next.set(next_state);
416}
417
418fn switch_to_previous_primitive(
419    current: Res<State<PrimitiveSelected>>,
420    mut next: ResMut<NextState<PrimitiveSelected>>,
421) {
422    let next_state = current.get().previous();
423    next.set(next_state);
424}
Source

pub fn set_if_neq(&mut self, state: S)

Tentatively set a pending state transition to Some(state).

Like set, but will not run any state transition schedules if the target state is the same as the current one. If set has already been called in the same frame with the same state, the transition schedules will be run anyways.

Source

pub fn reset(&mut self)

Remove any pending changes to State<S>

Trait Implementations§

Source§

impl<S> Clone for NextState<S>

Source§

fn clone(&self) -> NextState<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> Component for NextState<S>
where S: FreelyMutableState, NextState<S>: Send + Sync + 'static,

Source§

const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have Component<Mutability = Mutable>, while immutable components will instead have Component<Mutability = Immutable>. Read more
Source§

fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )

Registers required components. Read more
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn map_entities<M>(this: &mut NextState<S>, mapper: &mut M)
where M: EntityMapper,

Maps the entities on this component using the given EntityMapper. This is used to remap entities in contexts like scenes and entity cloning. When deriving Component, this is populated by annotating fields containing entities with #[entities] Read more
Source§

fn relationship_accessor() -> Option<ComponentRelationshipAccessor<NextState<S>>>

Returns ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read more
Source§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add ComponentHook for this Component if one is defined.
Source§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert ComponentHook for this Component if one is defined.
Source§

fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_discard ComponentHook for this Component if one is defined.
Source§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove ComponentHook for this Component if one is defined.
Source§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn ComponentHook for this Component if one is defined.
Source§

impl<S> Debug for NextState<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<S> Default for NextState<S>

Source§

fn default() -> NextState<S>

Returns the “default value” for a type. Read more
Source§

impl<S> Enum for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn field(&self, __name_param: &str) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field (in the current variant) with the given name. Read more
Source§

fn field_at( &self, __index_param: usize, ) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field (in the current variant) at the given index.
Source§

fn field_mut( &mut self, __name_param: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field (in the current variant) with the given name. Read more
Source§

fn field_at_mut( &mut self, __index_param: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field (in the current variant) at the given index.
Source§

fn index_of(&self, __name_param: &str) -> Option<usize>

Returns the index of the field (in the current variant) with the given name. Read more
Source§

fn name_at(&self, __index_param: usize) -> Option<&str>

Returns the name of the field (in the current variant) with the given index. Read more
Source§

fn iter_fields(&self) -> VariantFieldIter<'_>

Returns an iterator over the values of the current variant’s fields.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the current variant.
Source§

fn variant_name(&self) -> &str

The name of the current variant.
Source§

fn variant_index(&self) -> usize

The index of the current variant.
Source§

fn variant_type(&self) -> VariantType

The type of the current variant.
Source§

fn to_dynamic_enum(&self) -> DynamicEnum

Creates a new DynamicEnum from this enum.
Source§

fn is_variant(&self, variant_type: VariantType) -> bool

Returns true if the current variant’s type matches the given one.
Source§

fn variant_path(&self) -> String

Returns the full path to the current variant.
Source§

fn get_represented_enum_info(&self) -> Option<&'static EnumInfo>

Will return None if TypeInfo is not available.
Source§

impl<S> FromArg for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

type This<'from_arg> = NextState<S>

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<NextState<S> as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl<S> FromReflect for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn from_reflect( __param0: &(dyn PartialReflect + 'static), ) -> Option<NextState<S>>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl<S> GetOwnership for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl<S> GetTypeRegistration for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl<S> IntoReturn for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where NextState<S>: 'into_return,

Converts Self into a Return value.
Source§

impl<S> PartialReflect for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, __value_param: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<NextState<S>>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<NextState<S>>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<NextState<S>>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_partial_cmp( &self, value: &(dyn PartialReflect + 'static), ) -> Option<Ordering>

Returns a “partial comparison” result. Read more
Source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails.
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl<S> Reflect for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn into_any(self: Box<NextState<S>>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<NextState<S>>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl<S> Resource for NextState<S>
where S: FreelyMutableState, NextState<S>: Send + Sync + 'static,

Source§

impl<S> TypePath for NextState<S>

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl<S> Typed for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

Auto Trait Implementations§

§

impl<S> Freeze for NextState<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for NextState<S>
where S: RefUnwindSafe,

§

impl<S> Send for NextState<S>

§

impl<S> Sync for NextState<S>

§

impl<S> Unpin for NextState<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for NextState<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for NextState<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C> Bundle for C
where C: Component,

Source§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>

Source§

fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>

Return a iterator over this Bundle’s component ids. This will be None if the component has not been registered.
Source§

impl<C> BundleFromComponents for C
where C: Component,

Source§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>, C: Sized,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<C> DynamicBundle for C
where C: Component,

Source§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
Source§

unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Moves the components out of the bundle. Read more
Source§

unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )

Applies the after-effects of spawning this bundle. Read more
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> ErasedBundleTemplate for T
where T: Template + Send + Sync + 'static, <T as Template>::Output: Bundle,

Source§

unsafe fn apply( &self, context: &mut TemplateContext<'_, '_>, ) -> Result<(), BevyError>

Applies this template to the given entity. Read more
Source§

fn clone_template(&self) -> Box<dyn ErasedBundleTemplate>

Clones this template. See Clone.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

Source§

type Template = T

The Template for this type.
Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> HitDataExtra for T
where T: Send + Sync + Debug + Any + 'static,

Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<G> PatchFromTemplate for G
where G: FromTemplate,

Source§

type Template = <G as FromTemplate>::Template

The Template that will be patched.
Source§

fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
where F: FnOnce(&mut <G as PatchFromTemplate>::Template, &mut ResolveContext<'_>),

Takes a “patch function” func, and turns it into a TemplatePatch.
Source§

impl<T> PatchTemplate for T
where T: Template,

Source§

fn patch_template<F>(func: F) -> TemplatePatch<F, T>
where F: FnOnce(&mut T, &mut ResolveContext<'_>),

Takes a “patch function” func that patches this Template, and turns it into a TemplatePatch.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Reflectable for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> Template for T
where T: Clone + Default + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more