bevy/crates
Robert Walter 5f0abbfd15
Make standard commands more ergonomic (in niche cases) (#8249)
# Objective

I ran into a case where I need to create a `CommandQueue` and push
standard `Command` actions like `Insert` or `Remove` to it manually. I
saw that `Remove` looked as follows:

```rust
struct Remove<T> {
  entity: Entity,
  phantom: PhantomData<T>
}
```

so naturally, I tried to use `Remove::<Foo>::from(entity)` but it didn't
exist. We need to specify the `PhantomData` explicitly when creating
this command action. The same goes for `RemoveResource` and
`InitResource`

## Solution

This PR implements the following:

- `From<Entity>` for `Remove<T>`
- `Default` for `RemoveResource` and `InitResource`
- use these traits in the implementation of methods of `Commands`
- rename `phantom` field on the structs above to `_phantom` to have a
more uniform field naming scheme for the command actions

---

## Changelog

> This section is optional. If this was a trivial fix, or has no
externally-visible impact, you can delete this section.

- Added: implemented `From<Entity>` for `Remove<T>` and `Default` for
`RemoveResource` and `InitResource` for ergonomics

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2023-03-29 18:27:48 +00:00
..
bevy_a11y chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_animation Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_app Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_asset Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_audio Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_core Register missing types in bevy_window (#7993) 2023-03-27 21:48:29 +00:00
bevy_core_pipeline Split opaque and transparent phases (#8090) 2023-03-28 06:35:16 +00:00
bevy_derive chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_diagnostic Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_dylib chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_dynamic_plugin chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_ecs Make standard commands more ergonomic (in niche cases) (#8249) 2023-03-29 18:27:48 +00:00
bevy_ecs_compile_fail_tests Update trybuild tests for Rust 1.68 (#8002) 2023-03-09 15:46:06 +00:00
bevy_encase_derive chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_gilrs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_gizmos Fix segfault with 2d gizmos (#8223) 2023-03-29 18:05:03 +00:00
bevy_gltf chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_hierarchy Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_input Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_internal Document bevy_gizmos (#8186) 2023-03-28 20:58:02 +00:00
bevy_log chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_macro_utils Fix name conflicts caused by the SystemParam and WorldQuery macros (#8012) 2023-03-22 15:45:25 +00:00
bevy_math Re-export glam_assert feature (#8232) 2023-03-28 20:18:50 +00:00
bevy_mikktspace chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_pbr Use the prepass normal texture in main pass when possible (#8231) 2023-03-29 18:04:40 +00:00
bevy_ptr chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_reflect bevy_reflect: Fix trailing comma breaking derives (#8014) 2023-03-27 21:47:33 +00:00
bevy_reflect_compile_fail_tests bevy_reflect: Fix trailing comma breaking derives (#8014) 2023-03-27 21:47:33 +00:00
bevy_render Added WebP image format support (#8220) 2023-03-28 19:53:55 +00:00
bevy_scene Bugfix: Scene reload fix (nonbreaking) (#7951) 2023-03-27 22:18:45 +00:00
bevy_sprite Add ReflectComponent registration for Sprite (#8207) 2023-03-27 21:18:10 +00:00
bevy_tasks chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_text Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_time Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_transform docs: update docs and comments that still refer to stages (#8156) 2023-03-27 21:50:21 +00:00
bevy_ui Improve UI update_clipping_system comments (#8147) 2023-03-28 20:18:02 +00:00
bevy_utils chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_window Register missing types in bevy_window (#7993) 2023-03-27 21:48:29 +00:00
bevy_winit docs: update docs and comments that still refer to stages (#8156) 2023-03-27 21:50:21 +00:00