bevy/crates
UkoeHB ce32b5ca06
Add set_state extension method to Commands (#15083)
# Objective

- Improve the ergonomics of managing states.

## Solution

- Add `set_state` extension method to `Commands` so you don't need to
type out `ResMut<NextState<S>>` to update a state. It also reduces
system parameter list size when you already have `Commands`.
- I only updated a couple examples to showcase how it can be used. There
*is* a potential perf cost to introducing `Commands` so this method
shouldn't necessarily be used everywhere.

## Testing

- Tested the updated examples: `game_menu` and `alien_cake_addict`.

---

## Showcase

Add `Commands::set_state` method for easily updating states.

Set directly:
```rust
fn go_to_game(mut game_state: ResMut<NextState<GameState>>) {
    game_state.set(GameState::Play);
}
```

Set with commands (**NEW**):
```rust
fn go_to_game(mut commands: Commands) {
    commands.set_state(GameState::Play);
}
```
2024-09-09 15:58:09 +00:00
..
bevy_a11y Add Reflect derive to bevy_a11y::Focus (#14763) 2024-08-15 17:33:20 +00:00
bevy_animation Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_app Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_asset Add basic docs to AssetMode (#15057) 2024-09-09 15:33:29 +00:00
bevy_audio Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_color Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_core Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_core_pipeline Split OrthographicProjection::default into 2d & 3d (Adopted) (#15073) 2024-09-09 15:51:28 +00:00
bevy_derive Remove deprecated bevy_dynamic_plugin (#14534) 2024-07-30 15:31:08 +00:00
bevy_dev_tools Split OrthographicProjection::default into 2d & 3d (Adopted) (#15073) 2024-09-09 15:51:28 +00:00
bevy_diagnostic Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Remove remnant EntityHash and related types from bevy_utils (#15039) 2024-09-09 15:24:17 +00:00
bevy_encase_derive Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gilrs Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gizmos Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_gltf Split OrthographicProjection::default into 2d & 3d (Adopted) (#15073) 2024-09-09 15:51:28 +00:00
bevy_hierarchy Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_input Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_internal Remove all existing system order ambiguities in DefaultPlugins (#15031) 2024-09-03 20:24:34 +00:00
bevy_log Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_macro_utils Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_math Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_mikktspace Fix underflow panic in InitTriInfo (#14893) 2024-08-25 14:13:23 +00:00
bevy_pbr Replaced implicit emissive weight with default. (#13871) 2024-09-09 15:14:50 +00:00
bevy_picking Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_ptr Migrated NonZero* to NonZero<*> (#14978) 2024-08-30 02:37:47 +00:00
bevy_reflect Remove remnant EntityHash and related types from bevy_utils (#15039) 2024-09-09 15:24:17 +00:00
bevy_render Split OrthographicProjection::default into 2d & 3d (Adopted) (#15073) 2024-09-09 15:51:28 +00:00
bevy_scene Sorts the scene entries by path before serializing. (#15047) 2024-09-09 15:31:30 +00:00
bevy_sprite Remove deprecated SpriteSheetBundle and AtlasImageBundle (#15062) 2024-09-09 15:36:09 +00:00
bevy_state Add set_state extension method to Commands (#15083) 2024-09-09 15:58:09 +00:00
bevy_tasks Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_text Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_time Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_transform Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_ui Simplify pick_rounded_rect (#15065) 2024-09-09 15:40:00 +00:00
bevy_utils Remove remnant EntityHash and related types from bevy_utils (#15039) 2024-09-09 15:24:17 +00:00
bevy_window Unify crate-level preludes (#15080) 2024-09-08 17:10:57 +00:00
bevy_winit Picking event ordering (#14862) 2024-09-04 19:41:06 +00:00