-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Improve node encapsulation in ScheduleGraph
#20119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is getting much easier to understand!
crates/bevy_ecs/src/schedule/node.rs
Outdated
} | ||
} | ||
|
||
impl Deref for SystemWithAccess { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought using Deref
like this for "inheritence" was discouraged, and it was only supposed to be used for smart pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to get rid of some system.system
stutter, because for practically all intents and purposes a SystemWithAccess
is a System
. I'll leave this up to @alice-i-cecile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah Bevy's style guide disagrees with that advice. There's a reason we offer our own derive macros for Deref/DerefMut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative I suppose is impl System for SystemWithAccess
. I just want to avoid the stutter, really.
#[derive(Default)] | ||
pub struct Systems { | ||
/// List of systems in the schedule. | ||
nodes: SlotMap<SystemKey, SystemNode>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this would be more clear just storing Option<SystemWithNode>
instead of using the SystemNode
wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this was done in a previous pr. Feel free to ignore this then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SystemNode
will disappear entirely in my next PR (System
Arc
inization), so it shouldn't be staying around too much longer anyways.
Co-authored-by: Chris Russell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy enough with this :) Yay for smaller files too.
@ItsDoot I actually really like this idea. It's type-erased so it's not going to explode codegen. Are you willing to do that now? |
Another option here is to move the access to a separate storage, like another Either way, thank you for cleaning up the mess I made when I stuck the access there :). |
Done!
I quite like this idea, but I'll hold off on it at least until my next PR since those are likely to have similar blast-radii. |
Objective
We want to encapsulate each part of
ScheduleGraph
into its own specific struct to make parts of it easier to reuse and maintain.Solution
ScheduleGraph::systems
andScheduleGraph::system_conditions
into aSystems
struct and added a field for this new struct toScheduleGraph
ScheduleGraph::uninit
intoSystems::uninit
andSystemSets::uninit
to eliminateScheduleGraph
's direct field access of these typesScheduleGraph
; the same operations are now available onSystems
andSystemSets
instead (accessible via theirpub
fields onScheduleGraph
)Systems
,SystemSets
,SystemNode
,SystemWithAccess
, andConditionWithAccess
into a separate file.Testing
Added two new tests covering the API surface of
Systems
andSystemSets
, respectively.