Skip to content

Commit

Permalink
Allow registering boxed systems
Browse files Browse the repository at this point in the history
  • Loading branch information
aevyrie committed Nov 5, 2023
1 parent 02ce409 commit e8ee7b4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/bevy_ecs/src/system/system_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ impl World {
&mut self,
system: S,
) -> SystemId {
self.register_boxed_system(Box::new(IntoSystem::into_system(system)))
}

/// Similar to [`Self::register_system`], but allows passing in a [`BoxedSystem`].
///
/// This is useful if the [`IntoSystem`] implementor has already been turned into a
/// [`System`](crate::system::System) trait object and put in a [`Box`].
pub fn register_boxed_system(&mut self, system: BoxedSystem) -> SystemId {
SystemId(
self.spawn(RegisteredSystem {
initialized: false,
system: Box::new(IntoSystem::into_system(system)),
system,
})
.id(),
)
Expand Down

0 comments on commit e8ee7b4

Please sign in to comment.