bevy/crates
Torstein Grindvik 67aa2953d0 Extract component derive (#7399)
# Objective

In simple cases we might want to derive the `ExtractComponent` trait.
This adds symmetry to the existing `ExtractResource` derive.

## Solution

Add an implementation of `#[derive(ExtractComponent)]`.
The implementation is adapted from the existing `ExtractResource` derive macro.

Additionally, there is an attribute called `extract_component_filter`. This allows specifying a query filter type used when extracting.
If not specified, no filter (equal to `()`) is used.

So:

```rust
#[derive(Component, Clone, ExtractComponent)]
#[extract_component_filter(With<Fuel>)]
pub struct Car {
    pub wheels: usize,
}
```

would expand to (a bit cleaned up here):

```rust
impl ExtractComponent for Car
{
    type Query = &'static Self;
    type Filter = With<Fuel>;
    type Out = Self;
    fn extract_component(item: QueryItem<'_, Self::Query>) -> Option<Self::Out> {
        Some(item.clone())
    }
}
```

---

## Changelog

- Added the ability to `#[derive(ExtractComponent)]` with an optional filter.
2023-01-30 18:12:16 +00:00
..
bevy_animation Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_app Remove App::add_sub_app (#7290) 2023-01-24 21:24:25 +00:00
bevy_asset add UnsafeWorldCell abstraction (#6404) 2023-01-27 00:12:13 +00:00
bevy_audio AudioOutput is actually a normal resource now, not a non-send resource (#7262) 2023-01-18 17:20:26 +00:00
bevy_core Fix formatting in Name docs (#7384) 2023-01-27 17:49:11 +00:00
bevy_core_pipeline Extract component derive (#7399) 2023-01-30 18:12:16 +00:00
bevy_derive Fix ndk-macro link (#7027) 2022-12-25 05:06:03 +00:00
bevy_diagnostic Rename dynamic feature (#7340) 2023-01-23 14:28:00 +00:00
bevy_dylib Rename dynamic feature (#7340) 2023-01-23 14:28:00 +00:00
bevy_dynamic_plugin
bevy_ecs Fix unsoundness in EntityMut::world_scope (#7387) 2023-01-29 00:10:45 +00:00
bevy_ecs_compile_fail_tests
bevy_encase_derive add helper for macro to get either bevy::x or bevy_x depending on how it was imported (#7164) 2023-01-11 21:12:02 +00:00
bevy_gilrs Gamepad events refactor (#6965) 2023-01-09 19:24:52 +00:00
bevy_gltf enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00
bevy_hierarchy Add ReplaceChildren and ClearChildren EntityCommands (#6035) 2023-01-16 21:24:15 +00:00
bevy_input Fix small typo in gamepad.rs docs (#7411) 2023-01-29 20:11:46 +00:00
bevy_internal Docs: DefaultPlugins vs. MinimalPlugins and ScheduleRunnerPlugin (#7226) 2023-01-24 05:25:03 +00:00
bevy_log
bevy_macro_utils Update toml_edit to 0.18 (#7370) 2023-01-26 18:09:43 +00:00
bevy_math
bevy_mikktspace
bevy_pbr Extract component derive (#7399) 2023-01-30 18:12:16 +00:00
bevy_ptr Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_reflect Enable deriving Reflect on structs with generic types (#7364) 2023-01-28 00:12:06 +00:00
bevy_reflect_compile_fail_tests Enable deriving Reflect on structs with generic types (#7364) 2023-01-28 00:12:06 +00:00
bevy_render Extract component derive (#7399) 2023-01-30 18:12:16 +00:00
bevy_scene Fix beta clippy lints (#7154) 2023-01-11 09:51:22 +00:00
bevy_sprite Wgpu 0.15 (#7356) 2023-01-29 20:27:30 +00:00
bevy_tasks Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_text Allow users of Text/TextBundle to choose from glyph_brush_layout's BuiltInLineBreaker options. (#7283) 2023-01-21 00:17:11 +00:00
bevy_time re-enable tests on apple silicon (#7400) 2023-01-28 19:00:27 +00:00
bevy_transform Basic adaptive batching for parallel query iteration (#4777) 2023-01-20 08:47:20 +00:00
bevy_ui Extract component derive (#7399) 2023-01-30 18:12:16 +00:00
bevy_utils Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_window add Input Method Editor support (#7325) 2023-01-29 20:27:29 +00:00
bevy_winit add Input Method Editor support (#7325) 2023-01-29 20:27:29 +00:00