bevy/crates/bevy_sprite/src
Shane 484721be80
Have EntityCommands methods consume self for easier chaining (#14897)
# Objective

Fixes #14883

## Solution

Pretty simple update to `EntityCommands` methods to consume `self` and
return it rather than taking `&mut self`. The things probably worth
noting:

* I added `#[allow(clippy::should_implement_trait)]` to the `add` method
because it causes a linting conflict with `std::ops::Add`.
* `despawn` and `log_components` now return `Self`. I'm not sure if
that's exactly the desired behavior so I'm happy to adjust if that seems
wrong.

## Testing

Tested with `cargo run -p ci`. I think that should be sufficient to call
things good.

## Migration Guide

The most likely migration needed is changing code from this:

```
        let mut entity = commands.get_or_spawn(entity);

        if depth_prepass {
            entity.insert(DepthPrepass);
        }
        if normal_prepass {
            entity.insert(NormalPrepass);
        }
        if motion_vector_prepass {
            entity.insert(MotionVectorPrepass);
        }
        if deferred_prepass {
            entity.insert(DeferredPrepass);
        }
```

to this:

```
        let mut entity = commands.get_or_spawn(entity);

        if depth_prepass {
            entity = entity.insert(DepthPrepass);
        }
        if normal_prepass {
            entity = entity.insert(NormalPrepass);
        }
        if motion_vector_prepass {
            entity = entity.insert(MotionVectorPrepass);
        }
        if deferred_prepass {
            entity.insert(DeferredPrepass);
        }
```

as can be seen in several of the example code updates here. There will
probably also be instances where mutable `EntityCommands` vars no longer
need to be mutable.
2024-08-26 18:24:59 +00:00
..
mesh2d Have EntityCommands methods consume self for easier chaining (#14897) 2024-08-26 18:24:59 +00:00
render Add 2d opaque phase with depth buffer (#13069) 2024-08-07 00:22:09 +00:00
texture_slice fix asymmetrical 9-slicing (#14148) 2024-08-01 20:03:23 +00:00
bundle.rs new example: sprite animation in response to an event (#12996) 2024-04-23 21:44:03 +00:00
dynamic_texture_atlas_builder.rs Uncouple DynamicTextureAtlasBuilder from assets (#13717) 2024-06-08 12:38:03 +00:00
lib.rs Add bevy_picking sprite backend (#14757) 2024-08-26 18:01:32 +00:00
picking_backend.rs Add bevy_picking sprite backend (#14757) 2024-08-26 18:01:32 +00:00
sprite.rs Added Sprite::sized(custom_size) (#14849) 2024-08-21 12:24:16 +00:00
texture_atlas.rs Cosmic text (#10193) 2024-07-04 20:41:08 +00:00
texture_atlas_builder.rs More idiomatic texture atlas builder (#13238) 2024-06-03 12:43:50 +00:00