Skip to content

Add .with_system_set method to SystemSet #2722

Closed

Description

@alice-i-cecile

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

Reusing system sets is currently challenging: users may for example want to run a collection of systems in several states at once.

What solution would you like?

Add with_system_set to match with_system on the SystemSet struct.

What alternative(s) have you considered?

More completely overhaul / reorganize system sets and scheduling.

Additional context

This should be relatively straightforward for newcomers who want to get to know the ECS a bit better. Follow the impl here:

pub fn with_system<Params>(mut self, system: impl IntoSystemDescriptor<Params>) -> Self {

and push the systems from the new system set into self's corresponding field instead.

Activity

  1. added
    C-FeatureA new feature, making something new possible
    S-Needs-TriageThis issue needs to be labelled
    A-ECSEntities, components, systems, and events
    C-UsabilityA targeted quality-of-life change that makes Bevy easier to use
    D-TrivialNice and easy! A great choice to get started with Bevy
    and removed
    C-FeatureA new feature, making something new possible
    S-Needs-TriageThis issue needs to be labelled
    on Aug 24, 2021
  2. Zengor commented on Aug 24, 2021

    @Zengor

    Hi, looking into this. Two questions:

    • What should be done when both system sets have run criteria? Prioritize self's?
    • Should the other system set be consumed? Or taken as a reference + cloning its members? If the idea is to make reuse easier I guess the later is preferable but I'm not sure if this implicit cloning would be a problem. (actually it doesn't seem like SystemDescriptor even implements Clone)
  3. alice-i-cecile commented on Aug 24, 2021

    @alice-i-cecile
    MemberAuthor

    What should be done when both system sets have run criteria? Prioritize self's?

    Hmm. Prioritize self IMO? That will need to be clearly documented though.

    Should the other system set be consumed? Or taken as a reference + cloning its members? If the idea is to make reuse easier I guess the later is preferable but I'm not sure if this implicit cloning would be a problem. (actually it doesn't seem like SystemDescriptor even implements Clone)

    I don't mind implicit cloning here: this should be a one-time cost. IMO we should try to impl Clone for SystemDescriptor in this PR and then use that. I could see it being useful elsewhere as well for similar reuse patterns.

  4. Zengor commented on Aug 24, 2021

    @Zengor

    wrt implementing Clone, I ran into the issue that BoxedSystem and Box<dyn ExclusiveSystem> are not clonable and I'm not quite sure how to work around that (the systems themselves are functions using the function traits so I don't think they are clonable at all). Maybe there is some workaround that could be done with an Arc but I'm not sure where to go from here.

  5. alice-i-cecile commented on Aug 25, 2021

    @alice-i-cecile
    MemberAuthor

    Hmm. I think we should table this for the moment then; we can review it as the schedule and state story improves.

  6. added
    S-Needs-DesignThis issue requires design work to think about how it would best be accomplished
    and removed
    D-TrivialNice and easy! A great choice to get started with Bevy
    on Aug 25, 2021
  7. Ratysz commented on Aug 26, 2021

    @Ratysz
    Contributor

    You can't clone systems - there is, ordinarily, no point to doing that, and adding that restriction just for the sake of this API isn't a good idea. This is not going to "improve" in the future.

    What might be possible instead: introduce a Clone-like extension trait implemented on the descriptor obtained from clonable systems. I can't visualize how that's even going to work (descriptors are meant to be nongeneric), you might have to plumb in a whole pile of these traits and create a duplicate of most of descriptor logic but with cloning built in.

  8. cart commented on Aug 26, 2021

    @cart
    Member

    I think other scenarios tie in to this:

    • Running systems on a trigger (just passing an owned system each time it's needed isn't efficient, as has been proposed here run a system from a command #2234)
    • Running specific systems as "reactions"

    We already have ways to address systems:

    • SystemId
    • Labels

    Maybe we need a way to say things like:

    • "add all systems with LabelA to ScheduleThingY"
    • "add pre-existing SystemIdB to ScheduleThingZ"
    • "run SystemIdC once"
    • "run all systems with LabelD once"
  9. Ratysz commented on Aug 26, 2021

    @Ratysz
    Contributor

    I think other scenarios tie in to this: [...]

    They do, but this issue is kind of structured around the idea of cloning the systems.

    To me, a good solution for those would be a dedicated out-of-schedule storage for systems, indexed by labels and/or a kind of a unique key (system name?).

    Maybe we need a way to say things like: [...]

    We've been referring to this as "label properties": i.e., do things to systems by doing things to their labels. I don't think this is feasible to implement until we untangle the stages/states/lifecycle doom triangle, we need a completely flat systems storage if we want to do this sanely.

  10. added
    D-ComplexQuite challenging from either a design or technical perspective. Ask for help!
    on Dec 12, 2021
  11. james7132 commented on Feb 16, 2023

    @james7132
    Member

    SystemSets, as used prior to stageless, no longer exist. Closing this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions