bevy/crates
JaySpruce 0f2b2de333
Move some structs that impl Command to methods on World and EntityWorldMut (#16999)
## Objective

Commands were previously limited to structs that implemented `Command`.
Now there are blanket implementations for closures, which (in my
opinion) are generally preferable.

Internal commands within `commands/mod.rs` have been switched from
structs to closures, but there are a number of internal commands in
other areas of the engine that still use structs. I'd like to tidy these
up by moving their implementations to methods on
`World`/`EntityWorldMut` and changing `Commands` to use those methods
through closures.

This PR handles the following:
- `TriggerEvent` and `EmitDynamicTrigger` double as commands and helper
structs, and can just be moved to `World` methods.
- Four structs that enabled insertion/removal of components via
reflection. This functionality shouldn't be exclusive to commands, and
can be added to `EntityWorldMut`.
- Five structs that mostly just wrapped `World` methods, and can be
replaced with closures that do the same thing.

## Solution

- __Observer Triggers__ (`observer/trigger_event.rs` and
`observer/mod.rs`)
- Moved the internals of `TriggerEvent` to the `World` methods that used
it.
  - Replaced `EmitDynamicTrigger` with two `World` methods:
    - `trigger_targets_dynamic`
    - `trigger_targets_dynamic_ref`
- `TriggerTargets` was now the only thing in
`observer/trigger_event.rs`, so it's been moved to `observer/mod.rs` and
`trigger_event.rs` was deleted.
- __Reflection Insert/Remove__ (`reflect/entity_commands.rs`)
- Replaced the following `Command` impls with equivalent methods on
`EntityWorldMut`:
    - `InsertReflect` -> `insert_reflect`
    - `InsertReflectWithRegistry` -> `insert_reflect_with_registry`
    - `RemoveReflect` -> `remove_reflect`
    - `RemoveReflectWithRegistry` -> `remove_reflect_with_registry`
- __System Registration__ (`system/system_registry.rs`)
- The following `Command` impls just wrapped a `World` method and have
been replaced with closures:
    - `RunSystemWith`
    - `UnregisterSystem`
    - `RunSystemCachedWith`
    - `UnregisterSystemCached`
- `RegisterSystem` called a helper function that basically worked as a
constructor for `RegisteredSystem` and made sure it came with a marker
component. That helper function has been replaced with
`RegisteredSystem::new` and a `#[require]`.

## Possible Addition

The extension trait that adds the reflection commands,
`ReflectCommandExt`, isn't strictly necessary; we could just `impl
EntityCommands`. We could even move them to the same files as the main
impls and put it behind a `#[cfg]`.

The PR that added it [had a similar
conversation](https://github.com/bevyengine/bevy/pull/8895#discussion_r1234713671)
and decided to stick with the trait, but we could revisit it here if so
desired.
2024-12-29 22:18:53 +00:00
..
bevy_a11y Replace bevy_a11y::Focus with InputFocus (#16863) 2024-12-18 00:16:19 +00:00
bevy_animation Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_app Add SubApp::take_extract() (#16862) 2024-12-24 18:26:32 +00:00
bevy_asset Fix path checking for FileWatcher for virtual workspace projects (#16958) 2024-12-29 19:43:42 +00:00
bevy_audio Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_color Fix msrvs (#17012) 2024-12-29 20:00:19 +00:00
bevy_core_pipeline Fix Docs // incorrect default value for ChromaticAberration intensity (#16994) 2024-12-29 19:32:44 +00:00
bevy_derive Add benchmarks and compile_fail tests back to workspace (#16858) 2024-12-21 22:30:29 +00:00
bevy_dev_tools Draw the UI debug overlay using the UI renderer (#16693) 2024-12-11 00:49:47 +00:00
bevy_diagnostic Remove bevy_core (#16897) 2024-12-19 18:36:51 +00:00
bevy_dylib
bevy_ecs Move some structs that impl Command to methods on World and EntityWorldMut (#16999) 2024-12-29 22:18:53 +00:00
bevy_encase_derive Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_gilrs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
bevy_gizmos Refactor non-core Curve methods into extension traits (#16930) 2024-12-29 19:26:49 +00:00
bevy_gltf Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_hierarchy Add no_std support to bevy_hierarchy (#16998) 2024-12-29 19:12:29 +00:00
bevy_image Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_input Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_input_focus Fix msrvs (#17012) 2024-12-29 20:00:19 +00:00
bevy_internal Expose bevy_image as a feature (#16948) 2024-12-24 03:11:01 +00:00
bevy_log
bevy_macro_utils Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_math Fix msrvs (#17012) 2024-12-29 20:00:19 +00:00
bevy_mesh Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_mikktspace Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_pbr Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_picking Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_ptr Fix MSRVs for standalone crates (#16333) 2024-11-17 09:38:13 +00:00
bevy_reflect Add no_std support to bevy_hierarchy (#16998) 2024-12-29 19:12:29 +00:00
bevy_remote BRP registry JSON schema endpoint (#16882) 2024-12-26 22:14:08 +00:00
bevy_render Make RawHandleWrapper fields private to save users from themselves (#16968) 2024-12-29 19:54:57 +00:00
bevy_scene Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_sprite Remove unnecessary cast in DynamicTextureAtlasBuilder (#16937) 2024-12-24 17:14:06 +00:00
bevy_state Replace impl_param_set proc macro with a macro_rules macro (#16847) 2024-12-18 18:30:46 +00:00
bevy_tasks Move futures.rs, ConditionalSend and BoxedFuture types to bevy_tasks (#16951) 2024-12-29 19:29:53 +00:00
bevy_text Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_time
bevy_transform track_change_detection: Also track spawns/despawns (#16047) 2024-12-17 04:46:31 +00:00
bevy_ui Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
bevy_utils Move futures.rs, ConditionalSend and BoxedFuture types to bevy_tasks (#16951) 2024-12-29 19:29:53 +00:00
bevy_window Make RawHandleWrapper fields private to save users from themselves (#16968) 2024-12-29 19:54:57 +00:00
bevy_winit Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00