bevy/crates
UkoeHB adc2cf7dfe
Add state scoped events (#15085)
# Objective

- Improve robustness of state transitions. Currently events that should
be scoped to a specific state can leak between state scopes since events
live for two ticks.
- See https://github.com/bevyengine/bevy/issues/15072

## Solution

- Allow registering state scoped events that will be automatically
cleared when exiting a state. This is *most of the time* not obviously
useful, but enables users to write correct code that will avoid/reduce
edge conditions (such as systems that aren't state scoped polling for a
state scoped event and having unintended side effects outside a specific
state instance).

## Testing

Did not test.

---

## Showcase

Added state scoped events that will be automatically cleared when
exiting a state. Useful when you want to guarantee clean state
transitions.

Normal way to add an event:
```rust
fn setup(app: &mut App) {
    app.add_event::<MyGameEvent>();
}
```

Add a state-scoped event (**NEW**):
```rust
fn setup(app: &mut App) {
    app.add_state_scoped_event::<MyGameEvent>(GameState::Play);
}
```
2024-09-09 16:37:27 +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 Depreciate LoadAndSave Asset Processor (#15090) 2024-09-09 16:01:14 +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 Add common aspect ratio constants and improve documentation (#15091) 2024-09-09 16:04:41 +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 EntityRef/Mut get_components (immutable variants only) (#15089) 2024-09-09 16:29:44 +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 Add common aspect ratio constants and improve documentation (#15091) 2024-09-09 16:04:41 +00:00
bevy_mikktspace Fix underflow panic in InitTriInfo (#14893) 2024-08-25 14:13:23 +00:00
bevy_pbr bevy_pbr: Make choosing of diffuse indirect lighting explicit. (#15093) 2024-09-09 16:11:16 +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 bevy_reflect: Update on_unimplemented attributes (#15110) 2024-09-09 16:26:17 +00:00
bevy_render Add common aspect ratio constants and improve documentation (#15091) 2024-09-09 16:04:41 +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 state scoped events (#15085) 2024-09-09 16:37:27 +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 Retrieve the stack_index from Node in extract_ui_material_nodes instead of walking UiStack (#15104) 2024-09-09 16:18:37 +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