You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately the SystemParam approach currently used on master suffers from a safety hole. You can annotate system parameters like Res<'static, X> and suddenly we have a static pointer to a non-static resource! Thats bad!
To resolve this, I have adopted a "Fetch" pattern for SystemParams (the pattern used by WorldQueries).
This accomplishes two things:
Makes it impossible to convert a function with static references to a system
Removes the need to hack lifetimes inside of SystemParams, making the implementation much safer.
There is one major downside to this approach. We can no longer use this syntax:
app.add_system(movement)
Instead we must go back to doing this:
app.add_system(movement.system())
Yeah yeah ... I'm not happy about it either. But safety comes first. I'm hoping we find a magic implementation with no compromises, but until then something needs to give. And it can't be safety!
I encourage anyone interested to play around with the "minimal" examples in the link above. Maybe you can discover an ideal implementation.
calling a function on a function (my_system_function.system()) was one of the strange and surprising part of the API.
could we have a macro system!(my_system_function) that would do it for us? It doesn't change anything but I feel it would make the API easier to grasp
I'm pretty firmly anti-macro in that case. "no macros in the public ecs api" is one of my favorite parts of bevy, and is one of the things that distinguishes us from the other options out there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behavior
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1032
Unfortunately the SystemParam approach currently used on master suffers from a safety hole. You can annotate system parameters like
Res<'static, X>and suddenly we have a static pointer to a non-static resource! Thats bad!To resolve this, I have adopted a "Fetch" pattern for SystemParams (the pattern used by WorldQueries).
This accomplishes two things:
There is one major downside to this approach. We can no longer use this syntax:
Instead we must go back to doing this:
Yeah yeah ... I'm not happy about it either. But safety comes first. I'm hoping we find a magic implementation with no compromises, but until then something needs to give. And it can't be safety!
I encourage anyone interested to play around with the "minimal" examples in the link above. Maybe you can discover an ideal implementation.