bevy/crates/bevy_ecs/src/system
iiYese 5b899b48f5
Better SystemId to Entity conversions (#13090)
# Objective

- Better `SystemId` <-> `Entity` conversion.

## Solution

- Provide a method `SystemId::from_entity` to create a `SystemId<I, O>`
form an `Entity`. When users want to deal with the entities manually
they need a way to convert the `Entity` back to a `SystemId` to actually
run the system with `Commands` or `World`.
- Provide a method `SystemId::entity` that returns an `Entity` from
`SystemId`. The current `From` impl is not very discoverable as it does
not appear on the `SystemId` doc page.
- Remove old `From` impl.

## Migration Guide

```rust
let system_id = world.register_system(my_sys);

// old
let entity = Entity::from(system_id);

// new
let entity = system_id.entity();
```

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-04-25 18:47:49 +00:00
..
commands Better SystemId to Entity conversions (#13090) 2024-04-25 18:47:49 +00:00
adapter_system.rs bevy_ecs address trivial cases of unsafe_op_in_unsafe_fn (#11861) 2024-02-22 00:04:38 +00:00
combinator.rs bevy_ecs address trivial cases of unsafe_op_in_unsafe_fn (#11861) 2024-02-22 00:04:38 +00:00
exclusive_function_system.rs Component Lifecycle Hooks and a Deferred World (#10756) 2024-03-01 14:59:22 +00:00
exclusive_system_param.rs impl ExclusiveSystemParam for PhantomData (#11153) 2024-01-01 16:02:21 +00:00
function_system.rs Make SystemParam::new_archetype and QueryState::new_archetype unsafe functions (#13044) 2024-04-21 02:49:42 +00:00
mod.rs Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
query.rs Add #[track_caller] to Query methods (#12984) 2024-04-24 04:51:18 +00:00
system.rs Fix uses of "it's" vs "its". (#13033) 2024-04-19 18:17:31 +00:00
system_name.rs impl ExclusiveSystemParam for SystemName (#11163) 2024-01-01 17:08:29 +00:00
system_param.rs Make SystemParam::new_archetype and QueryState::new_archetype unsafe functions (#13044) 2024-04-21 02:49:42 +00:00
system_registry.rs Better SystemId to Entity conversions (#13090) 2024-04-25 18:47:49 +00:00