bevy/crates/bevy_ecs/macros/src
Chris Russell 4be8e497ca
SystemParamBuilder - Allow deriving a SystemParamBuilder struct when deriving SystemParam. (#14818)
# Objective

Allow `SystemParamBuilder` implementations for custom system parameters
created using `#[derive(SystemParam)]`.

## Solution

Extend the derive macro to accept a `#[system_param(builder)]`
attribute. When present, emit a builder type with a field corresponding
to each field of the param.

## Example

```rust
#[derive(SystemParam)]
#[system_param(builder)]
struct CustomParam<'w, 's> {
    query: Query<'w, 's, ()>,
    local: Local<'s, usize>,
}

let system = (CustomParamBuilder {
    local: LocalBuilder(100),
    query: QueryParamBuilder::new(|builder| {
        builder.with::<A>();
    }),
},)
    .build_state(&mut world)
    .build_system(|param: CustomParam| *param.local + param.query.iter().count());
```
2024-08-28 18:24:52 +00:00
..
component.rs Required Components (#14791) 2024-08-27 20:22:23 +00:00
lib.rs SystemParamBuilder - Allow deriving a SystemParamBuilder struct when deriving SystemParam. (#14818) 2024-08-28 18:24:52 +00:00
query_data.rs Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
query_filter.rs Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
states.rs Computed State & Sub States (#11426) 2024-05-02 19:36:23 +00:00
world_query.rs Add query reborrowing (#14690) 2024-08-15 17:38:56 +00:00