Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,28 @@
<!-- https://github.com/bevyengine/bevy/pull/13818 -->

<!-- TODO -->

When working with complex event-driven logic, you may find that you want to conditionally modify events without changing their type or re-emitting them.
While this has always been possible, it was quite onerous:

```rust
// We need to manually track which events this system has read
// using a system-local `EventCursor`, previously called `ManualEventReader`.
fn mutate_events(mut events: ResMut<Events<MyEvent>>, mut local_cursor: Local<EventCursor<MyEvent>>){
for event in local_cursor.read_mut(&mut *events){
event.mutate();
}
}
```

Now, you can simply use the new [`EventMutator`] system param, which keeps track of this bookkeeping for you.

```rust
fn mutate_events(mut event_mutator: EventMutator<MyEvent>>){
for event in event_mutator.read(){
event.mutate();
}
}
```

[`EventMutator`]: https://docs.rs/bevy/0.15/bevy/ecs/event/struct.EventMutator.html
5 changes: 2 additions & 3 deletions release-content/0.15/release-notes/_release-notes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ prs = [14071]
file_name = "14071_Uniform_mesh_sampling.md"

[[release_notes]]
title = "Created an EventMutator for when you want to mutate an event before reading"
title = "`EventMutator`"
authors = ["@BobG1983"]
contributors = ["@atornity", "@alice-i-cecile"]
prs = [13818]
Expand Down Expand Up @@ -467,8 +467,7 @@ file_name = "15800_Add_mesh_picking_backend_and_MeshRayCast_system_parameter.md"

[[release_notes]]
title = "Required Components"
authors = ["@cart",]
authors = ["@cart"]
contributors = ["@alice-i-cecile", "@killercup", "@BD103"]
prs = [14791]
file_name = "14791_Required_Components.md"