bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.36k stars 3.59k forks source link

Access registered systems. #15855

Open Phoqinu opened 1 month ago

Phoqinu commented 1 month ago

What problem does this solve or what need does it fill?

Systems part of Schedule can be accessed and "inspected". That is you can get some info of the system from System trait. But registered systems are opaque because their storage is private. They exist as entities and are stored inside RegisteredSystem component.

What solution would you like?

Make the RegisteredSystem component pub (and re-export it ?) and add method to borrow stored system pub fn system_ref(&self) -> &BoxedSystem<I, O>; or pub fn system_ref(&self) -> &dyn System<In = I, Out = O>;

What alternative(s) have you considered?

EDIT: If users should have same rights as bevy then I think it should be pub and it's members too. Then there would be no need to system getter. Or maybe add method which converts RegisteredSystem to RemovedSystem ? pub fn remove(self) -> RemovedSystem;

Which one ?

Additional context

None.

Phoqinu commented 1 month ago

If this gets approved and it will be easy to impl as I offered in What solution would you like? then I would like to take it :)

alice-i-cecile commented 1 month ago

I'm a bit nervous about this, because it's very implementation focused, rather than motivation focused [6:40 PM]Alice 🌹: There are a lot of reasonable things that you might want to do with this access! [6:41 PM]Alice 🌹: But unless that's actually written up in the issue and PR, it's going to be hard to find the right design [6:41 PM]Alice 🌹: And liable to getting reverted by mistake