bevy/crates/bevy_asset/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
..
io fix typo processed_dir (#14220) 2024-07-08 11:29:40 +00:00
processor Fix lints introduced in Rust beta 1.80 (#13899) 2024-06-17 17:22:01 +00:00
server Fix crash when an asset load failure event is processed after asset drop (#14123) 2024-07-08 00:58:55 +00:00
assets.rs Avoid a panic when loading labelled assets (#13506) 2024-06-05 23:04:52 +00:00
direct_access_ext.rs Add methods to directly load assets from World (#12023) 2024-02-27 00:28:26 +00:00
event.rs Added AssetLoadFailedEvent, UntypedAssetLoadFailedEvent (#11369) 2024-01-17 21:12:00 +00:00
folder.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
handle.rs Add a test asserting that reflected cloning a Handle increments strong count (#13961) 2024-06-24 20:54:54 +00:00
id.rs Allow phase items not associated with meshes to be binned. (#14029) 2024-06-27 16:13:03 +00:00
lib.rs Created an EventMutator for when you want to mutate an event before reading (#13818) 2024-07-08 14:53:06 +00:00
loader.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
loader_builders.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
meta.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
path.rs Apply Clippy lints regarding lazy evaluation and closures (#14015) 2024-07-01 15:54:40 +00:00
reflect.rs Apply Clippy lints regarding lazy evaluation and closures (#14015) 2024-07-01 15:54:40 +00:00
saver.rs Use async-fn in traits rather than BoxedFuture (#12550) 2024-03-18 17:56:57 +00:00
transformer.rs Use async-fn in traits rather than BoxedFuture (#12550) 2024-03-18 17:56:57 +00:00