Skip to content
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

Run once dynamically called system #6798

Closed
DasLixou opened this issue Nov 29, 2022 · 3 comments
Closed

Run once dynamically called system #6798

DasLixou opened this issue Nov 29, 2022 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Enhancement A new feature

Comments

@DasLixou
Copy link
Contributor

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

Ok so the name isn’t that great but I’ll try to explain what I mean.
Currently, when you have a simple system that doesn’t need any resources or so other than a simple query, and it may call code (maybe with if statement, so it could be called, but mustn’t) which needs more components and other resources, you have to implement them in the system, just to pass them to the next function. This is messy and also not ideal. So i want a new parameter for system where they can slide in and schedule new systems.

What solution would you like?

Something like this:

#[derive(SystemLabel)]
enum MyLabels {
    First,
    Second,
}

fn main() {
    App::new()
        .add_system(main_thing.label(MyLabels::First))
        .add_system(info_thing.label(MyLabels::Second).after(MyLabels::First))
        .add_plugins(DefaultPlugins)
        .run();
}

fn main_thing(mut scheduler: SystemScheduler) {
    if random(10) <= 5 {
        scheduler.schedule_once(perhaps_system.label(MyLabels::First)); // this will still run before info_thing
    }
}

fn perhaps_system(mut query: Query<..>, mut my_cool_resource: ResMut<Cool>) {
    // here we can do things with them without any nasty code in main_thing :)
}

fn info_thing() { .. }

What alternative(s) have you considered?

Still using the nasty code with unused parameters and piping them through functions.

Additional context

it would really be nice if this would be possible with the new stageless concept :)

@DasLixou DasLixou added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Nov 29, 2022
@james7132 james7132 added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Nov 30, 2022
@DasLixou
Copy link
Contributor Author

DasLixou commented Dec 2, 2022

:o just found out that #4090 would make it :D

@wilk10
Copy link
Contributor

wilk10 commented Feb 6, 2023

Is this a duplicate of #2192 ?

@DasLixou
Copy link
Contributor Author

DasLixou commented Feb 6, 2023

Yes it is

@DasLixou DasLixou closed this as completed Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Enhancement A new feature
Projects
None yet
Development

No branches or pull requests

3 participants