bevy/crates/bevy_ecs/src
Pablo Reinhardt 78335a5ddc
Allow Commands to register systems (#11019)
# Objective

- Allow registering of systems from Commands with
`Commands::register_one_shot_system`
- Make registering of one shot systems more easy

## Solution

- Add the Command `RegisterSystem` for Commands use.
- Creation of SystemId based on lazy insertion of the System
- Changed the privacy of the fields in SystemId so Commands can return
the SystemId

---

## Changelog

### Added
- Added command `RegisterSystem`
- Added function `Commands::register_one_shot_system`
- Added function `App::register_one_shot_system`

### Changed
- Changed the privacy and the type of struct tuple to regular struct of
SystemId

## Migration Guide

- Changed SystemId fields from tuple struct to a normal struct
If you want to access the entity field, you should use
`SystemId::entity` instead of `SystemId::0`

## Showcase
> Before, if you wanted to register a system with `Commands`, you would
need to do:
```rust
commands.add(|world: &mut World| {
    let id = world.register_system(your_system);
    // You would need to insert the SystemId inside an entity or similar
})
```
> Now, you can:
```rust
let id = commands.register_one_shot_system(your_system);
// Do what you want with the Id

```

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Pablo Reinhardt <pabloreinhardt@gmail.com>
2024-03-22 17:31:40 +00:00
..
entity Fix inconsistency between Debug and serialized representation of Entity (#12469) 2024-03-14 14:57:22 +00:00
identifier fix some typos (#12038) 2024-02-22 18:55:22 +00:00
query Update ecs query docs (#12595) 2024-03-22 13:28:41 +00:00
reflect Move commands module into bevy::ecs::world (#12234) 2024-03-02 23:13:45 +00:00
schedule Split ScheduleGraph::process_configs function (adopted) (#12435) 2024-03-17 02:00:37 +00:00
storage Use NonMaxUsize for non-component SparseSets (#12083) 2024-03-03 14:55:27 +00:00
system Allow Commands to register systems (#11019) 2024-03-22 17:31:40 +00:00
world Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
archetype.rs Query Joins (#11535) 2024-03-11 19:07:36 +00:00
bundle.rs Clean up pointer use in BundleSpawner/BundleInserter (#12269) 2024-03-06 05:52:18 +00:00
change_detection.rs Implement MutUntyped::from(mut_typed) (#12406) 2024-03-10 12:46:50 +00:00
component.rs Remove ComponentStorage and associated types (#12311) 2024-03-05 15:54:52 +00:00
event.rs Fix bug where events are not being dropped (#11528) 2024-02-02 21:14:54 +00:00
lib.rs Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
removal_detection.rs Docs reflect that RemovalDetection also yields despawned entities (#11795) 2024-02-10 11:18:05 +00:00