-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Read-only queries cannot be issued on a read-only &World #3774
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Problem
Given a
&World, I cannot issue a query that only reads from the world.There are two possible methods on
Worldfor this:query,query_filtered, plusSystemState::new(). All of them require&mut World, as they could provide mutating type parameters.Proposed Solutions
Quick-and-dirty
Make read-only variants of all three methods.
Ergonomic
Add a
system_stateandread_only_system_statemethod toWorld, which generates aSystemStateand then immediately calls.get_mut/.geton it.This allows users to do things like: