Fix hang on missing state update handler (#1051)

This commit is contained in:
sapir 2020-12-13 21:55:32 +02:00 committed by GitHub
parent 9a4327b3e2
commit 002e22fca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,7 +98,7 @@ impl<T: Resource + Clone> Stage for StateStage<T> {
}
fn run(&mut self, world: &mut World, resources: &mut Resources) {
loop {
let current_stage = loop {
let (next_stage, current_stage) = {
let mut state = resources
.get_mut::<State<T>>()
@ -132,14 +132,17 @@ impl<T: Resource + Clone> Stage for StateStage<T> {
{
enter_next.run(world, resources);
}
} else if let Some(update_current) = self
.stages
.get_mut(&current_stage)
.and_then(|stage| stage.update.as_mut())
{
update_current.run(world, resources);
break;
} else {
break current_stage;
}
};
if let Some(update_current) = self
.stages
.get_mut(&current_stage)
.and_then(|stage| stage.update.as_mut())
{
update_current.run(world, resources);
}
}
}