bevy/crates/bevy_winit/src
Bob Gardner ec1aa48fc6
Created an EventMutator for when you want to mutate an event before reading (#13818)
# Objective

- Often in games you will want to create chains of systems that modify
some event. For example, a chain of damage systems that handle a
DamageEvent and modify the underlying value before the health system
finally consumes the event. Right now this requires either:

* Using a component added to the entity
* Consuming and refiring events

Neither is ideal when really all we want to do is read the events value,
modify it, and write it back.

## Solution

- Create an EventMutator class similar to EventReader but with ResMut<T>
and iterators that return &mut so that events can be mutated.

## Testing

- I replicated all the existing tests for EventReader to make sure
behavior was the same (I believe) and added a number of tests specific
to testing that 1) events can actually be mutated, and that 2)
EventReader sees changes from EventMutator for events it hasn't already
seen.

## Migration Guide

Users currently using `ManualEventReader` should use `EventCursor`
instead. `ManualEventReader` will be removed in Bevy 0.16. Additionally,
`Events::get_reader` has been replaced by `Events::get_cursor`.

Users currently directly accessing the `Events` resource for mutation
should move to `EventMutator` if possible.

---------

Co-authored-by: poopy <gonesbird@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-07-08 14:53:06 +00:00
..
accessibility.rs fix: upgrade to winit v0.30 (#13366) 2024-06-03 13:06:48 +00:00
converters.rs Add logical key data to KeyboardInput (#11400) 2024-01-22 15:25:17 +00:00
lib.rs fix: upgrade to winit v0.30 (#13366) 2024-06-03 13:06:48 +00:00
state.rs Created an EventMutator for when you want to mutate an event before reading (#13818) 2024-07-08 14:53:06 +00:00
system.rs apply window scale to window size when creating it (#13967) 2024-06-21 18:04:57 +00:00
winit_config.rs Fix lints introduced in Rust beta 1.80 (#13899) 2024-06-17 17:22:01 +00:00
winit_event.rs flush key_input cache when Bevy loses focus (Adopted) (#13678) 2024-06-05 02:06:47 +00:00
winit_windows.rs Have WindowPosition::Centered take scale_factor_override into account (#13949) 2024-06-24 20:56:46 +00:00