diff --git a/framework_crates/bones_ecs/src/world.rs b/framework_crates/bones_ecs/src/world.rs index ef49599f4f..b368b7a2b3 100644 --- a/framework_crates/bones_ecs/src/world.rs +++ b/framework_crates/bones_ecs/src/world.rs @@ -94,6 +94,9 @@ impl World { /// /// If all the system parameters have already been initialized, by calling /// [`initialize()`][System::initialize] on the system, then this will work fine. + /// + /// You can also use [`world.init_param()`][Self::init_param] to manually initialize specific + /// parameters if you know which ones will need to be initialized. pub fn run_initialized_system<'system, Args, In, Out, S>(&self, system: S, input: In) -> Out where In: 'system, @@ -114,6 +117,16 @@ impl World { self.resource_mut() } + /// Initialize a system parameter. + /// + /// It is not necessary to do this manually unless you are going to run a system using + /// [`world.run_initialized_system()`][Self::run_initialized_system()] and you need to make sure + /// one of it's parameters are pre-initialized. + pub fn init_param(&mut self) -> &mut Self { + P::initialize(self); + self + } + /// Insert a resource. pub fn insert_resource(&mut self, resource: R) -> Option> { self.resources.insert(resource)