Skip to content

Add SystemIdTemplate to allow one-shot system in bsn!#24026

Draft
hxYuki wants to merge 5 commits intobevyengine:mainfrom
hxYuki:system-id-template
Draft

Add SystemIdTemplate to allow one-shot system in bsn!#24026
hxYuki wants to merge 5 commits intobevyengine:mainfrom
hxYuki:system-id-template

Conversation

@hxYuki
Copy link
Copy Markdown
Contributor

@hxYuki hxYuki commented Apr 29, 2026

Objective

Solution

  • Add SystemIdTemplate
  • Implement FromTemplate for SystemId
  • Add a helper function system_value<M> to convert a system to SystemIdTemplate

Testing

  • A ad-hoc test nested in 3d_scene.

Showcase

#[derive(Component, FromTemplate)]
struct Callback(SystemId);

fn callback_scene() -> impl SceneList {
    bsn_list! {
        Callback(system_value(|| {
            println!("Hello from the callback!");
        })),
        Callback(system_value(callback_system)),
    }
}

fn callback_system(){
    println!("Hello from the system!");
}

Co-authored-by: Copilot <copilot@github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨

@hxYuki
Copy link
Copy Markdown
Contributor Author

hxYuki commented Apr 29, 2026

Not sure where to place these codes. I've searched impl FromTemplate for in repo and got only Entity here.

Comment thread crates/bevy_ecs/src/template.rs Outdated

impl Default for SystemIdTemplate {
fn default() -> Self {
Self::BoxedSystem(Arc::new(Mutex::new(Some(Box::new(IntoSystem::into_system(|| {}))))))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the default value for a SystemId?

Comment thread crates/bevy_ecs/src/template.rs Outdated
Comment thread crates/bevy_ecs/src/template.rs Outdated
Comment thread crates/bevy_ecs/src/template.rs Outdated
@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events A-Scenes Composing and serializing ECS objects labels Apr 29, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in ECS Apr 29, 2026
@alice-i-cecile alice-i-cecile added D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Apr 29, 2026
Co-authored-by: Copilot <copilot@github.com>
Comment thread crates/bevy_ecs/src/template.rs Outdated
Comment thread crates/bevy_ecs/src/template.rs Outdated
@hxYuki hxYuki requested a review from SkiFire13 May 3, 2026 09:41
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 A-Scenes Composing and serializing ECS objects C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

Allow registering one-shot system in bsn!

3 participants