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

'enter' stage not called in some cases #1117

Closed
Illthiriel opened this issue Dec 21, 2020 · 3 comments
Closed

'enter' stage not called in some cases #1117

Illthiriel opened this issue Dec 21, 2020 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior
Milestone

Comments

@Illthiriel
Copy link

Illthiriel commented Dec 21, 2020

Bevy version

bevy 0.4.0

Operating system & version

Windows 10

What you did

The following code allow to reproduce the issue. If I uncomment the add_stage_before line, the enter_system is not called anymore.

use bevy::prelude::*;

#[derive(Clone)]
pub enum AppState {
    Loading,
}

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_resource(State::new(AppState::Loading))
        // uncomment the next line and 'enter_system' is not called
        // .add_stage_before(stage::UPDATE, "STAGE_1", StateStage::<AppState>::default())
        .add_stage_after(stage::UPDATE, "STAGE_2", StateStage::<AppState>::default()
            .with_enter_stage(
                AppState::Loading,
                SystemStage::parallel()
                    .with_system(enter_system.system()),
            )
            .with_update_stage(
                AppState::Loading,
                SystemStage::parallel()
                    .with_system(update_system.system()),
            ))
        .run();
}

pub fn enter_system() {
    println!("enter_system");
}

pub fn update_system() {
    println!("update_system");
}

What you expected to happen

The 'enter' should be called.

What actually happened

The 'enter' is not called.

DJMcNab added a commit to DJMcNab/bevy that referenced this issue Dec 21, 2020
Extends bevyengine#1021
Fixes bevyengine#1117
This also allows avoiding the Clone bound on state

Possible future work:
- Make state use Eq instead
@memoryruins memoryruins added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events labels Dec 22, 2020
@TheNeikos
Copy link
Contributor

TheNeikos commented Feb 9, 2021

The same issue seems to happen with exit:

use bevy::prelude::*;

#[derive(Clone)]
pub enum AppState {
    Loading,
    Loaded,
}

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_resource(State::new(AppState::Loading))
        // uncomment the next line and 'enter_system' is not called
        // .add_stage_before(stage::UPDATE, "STAGE_1", StateStage::<AppState>::default())
        .add_stage_after(
            stage::UPDATE,
            "STAGE_2",
            StateStage::<AppState>::default()
                .with_enter_stage(
                    AppState::Loading,
                    SystemStage::single(enter_system.system()),
                )
                .with_update_stage(
                    AppState::Loading,
                    SystemStage::single(update_system.system()),
                )
                .with_exit_stage(AppState::Loading, SystemStage::single(exit_system.system())),
        )
        .run();
}

pub fn enter_system() {
    println!("enter_system");
}

pub fn update_system(mut state: ResMut<State<AppState>>) {
    println!("update_system");
    state.set_next(AppState::Loaded).unwrap();
}

pub fn exit_system() {
    println!("exit_system");
}

@TheRawMeatball
Copy link
Member

This should be resolved by #1424

@alice-i-cecile alice-i-cecile added this to the Bevy 0.5 milestone Feb 17, 2021
@cart
Copy link
Member

cart commented Mar 17, 2021

Closing as #1424 is merged

@cart cart closed this as completed Mar 17, 2021
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-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants