add allow_all and deny_all methods to DynamicSceneBuilder (#15222)

# Objective

It would be convenient to be able to quickly deny or allow all
components and resources on a `DynamicSceneBuilder` with a single method
call.

Context: #15210 renamed `{allow/deny}_all` to
`{allow/deny}_all_components`.

## Solution

Added two new methods to `DynamicSceneBuilder`, `allow_all` and
`deny_all`, which affect both the component and resource filters.


## Showcase

### Before

```rust
let builder = DynamicSceneBuilder::from_world(world)
    .deny_all_components()
    .deny_all_resources();
```

### After

```rust
let builder = DynamicSceneBuilder::from_world(world).deny_all();
```
This commit is contained in:
poopy 2024-09-15 17:30:53 +02:00 committed by GitHub
parent 228ce8170a
commit d878e2f8bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -88,6 +88,26 @@ impl<'w> DynamicSceneBuilder<'w> {
self self
} }
/// Updates the filter to allow all component and resource types.
///
/// This is useful for resetting the filter so that types may be selectively denied
/// with [`deny_component`](`Self::deny_component`) and [`deny_resource`](`Self::deny_resource`).
pub fn allow_all(mut self) -> Self {
self.component_filter = SceneFilter::allow_all();
self.resource_filter = SceneFilter::allow_all();
self
}
/// Updates the filter to deny all component and resource types.
///
/// This is useful for resetting the filter so that types may be selectively allowed
/// with [`allow_component`](`Self::allow_component`) and [`allow_resource`](`Self::allow_resource`).
pub fn deny_all(mut self) -> Self {
self.component_filter = SceneFilter::deny_all();
self.resource_filter = SceneFilter::deny_all();
self
}
/// Allows the given component type, `T`, to be included in the generated scene. /// Allows the given component type, `T`, to be included in the generated scene.
/// ///
/// This method may be called multiple times for any number of components. /// This method may be called multiple times for any number of components.