Use try_resource_scope instead of manually checking
This commit is contained in:
parent
c8b1dccfe6
commit
3e8d45a719
@ -31,20 +31,16 @@ pub fn signal_event_update_system(signal: Option<ResMut<EventRegistry>>) {
|
||||
|
||||
/// A system that calls [`Events::update`](super::Events::update) on all registered [`Events`][super::Events] in the world.
|
||||
pub fn event_update_system(world: &mut World, mut last_change_tick: Local<Tick>) {
|
||||
if world.contains_resource::<EventRegistry>() {
|
||||
world.resource_scope(|world, mut registry: Mut<EventRegistry>| {
|
||||
registry.run_updates(world, *last_change_tick);
|
||||
world.try_resource_scope(|world, mut registry: Mut<EventRegistry>| {
|
||||
registry.run_updates(world, *last_change_tick);
|
||||
|
||||
registry.should_update = match registry.should_update {
|
||||
// If we're always updating, keep doing so.
|
||||
ShouldUpdateEvents::Always => ShouldUpdateEvents::Always,
|
||||
// Disable the system until signal_event_update_system runs again.
|
||||
ShouldUpdateEvents::Waiting | ShouldUpdateEvents::Ready => {
|
||||
ShouldUpdateEvents::Waiting
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
registry.should_update = match registry.should_update {
|
||||
// If we're always updating, keep doing so.
|
||||
ShouldUpdateEvents::Always => ShouldUpdateEvents::Always,
|
||||
// Disable the system until signal_event_update_system runs again.
|
||||
ShouldUpdateEvents::Waiting | ShouldUpdateEvents::Ready => ShouldUpdateEvents::Waiting,
|
||||
};
|
||||
});
|
||||
*last_change_tick = world.change_tick();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user