pub struct App {
pub world: World,
pub render_world: World,
pub extract_fns: Vec<ExtractFn>,
pub desired_threads: usize,
pub installed_plugins: HashMap<&'static str, Box<dyn PluginMetadata>>,
/* private fields */
}Expand description
Lumen application holding the main world, render world, their schedules, and the extract-fn list.
Fields§
§world: WorldMain world carrying app/UI state, layout, and scripts.
render_world: WorldRender world carrying per-frame extracted draw data and GPU resources.
extract_fns: Vec<ExtractFn>Extract fns invoked in registration order each tick, after the main schedule and before the render schedule.
App::new seeds the list with the built-in extractors and App::add_extract_fn appends to it. The list is
public so a plugin can also replace or reorder an entry; nothing in the workspace does that today.
desired_threads: usizeWorker-thread budget for the bevy_ecs multithreaded executor.
- Defaults to
LUMEN_DEFAULT_THREADS(4). - Plugins raise it monotonically via
Self::request_threads_at_least. - The
LUMEN_THREADSenvironment variable overrides any plugin request. - Read at the first
Self::tick; the task pool is initialised once viaComputeTaskPool::get_or_initand subsequent updates have no effect.
installed_plugins: HashMap<&'static str, Box<dyn PluginMetadata>>Plugin name -> metadata. Populated by Self::add_plugin in installation order.
Implementations§
Source§impl App
impl App
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a fresh app with both worlds, both schedules, the command queue, and the default extract fns.
Sourcepub fn add_message<M: Message>(&mut self) -> &mut Self
pub fn add_message<M: Message>(&mut self) -> &mut Self
Registers a message type with [MessageRegistry] so bevy_ecs::message::MessageWriter and bevy_ecs::message::MessageReader can be used for M.
Sourcepub fn add_plugin<P: Plugin + 'static>(&mut self, plugin: P) -> &mut Self
pub fn add_plugin<P: Plugin + 'static>(&mut self, plugin: P) -> &mut Self
Calls plugin.build(self), consuming the plugin.
Records the plugin’s metadata in Self::installed_plugins so Self::is_plugin_added and other queries can
answer without re-running the build closure. Logs (but does not panic) when a declared depends_on entry has
not been installed yet - wave 1 wires the topological sort that would defer the build instead.
Sourcepub fn is_plugin_added<P: Plugin + 'static>(&self) -> bool
pub fn is_plugin_added<P: Plugin + 'static>(&self) -> bool
Returns true when a plugin of type P has been installed via Self::add_plugin.
Sourcepub fn plugin_added(&self, name: &str) -> bool
pub fn plugin_added(&self, name: &str) -> bool
Returns true when a plugin with the supplied Plugin::name has been installed.
Sourcepub fn register_command<T, F>(&mut self, handler: F) -> &mut Self
pub fn register_command<T, F>(&mut self, handler: F) -> &mut Self
Registers a strongly-typed handler invoked when a Command::Typed payload of type T is drained.
Replaces the legacy blind Command::Custom(Box<dyn Any>) downcast pattern: producers build
Command::Typed { type_id: TypeId::of::<T>(), payload: Box::new(value) }, the drain looks up the handler by
type id and invokes it with the typed payload.
Sourcepub fn add_systems<M>(
&mut self,
stage: TickStage,
systems: impl IntoScheduleConfigs<ScheduleSystem, M>,
) -> &mut Self
pub fn add_systems<M>( &mut self, stage: TickStage, systems: impl IntoScheduleConfigs<ScheduleSystem, M>, ) -> &mut Self
Adds main-world systems into the Tick schedule under the given TickStage set.
Sourcepub fn add_render_systems<M>(
&mut self,
stage: RenderStage,
systems: impl IntoScheduleConfigs<ScheduleSystem, M>,
) -> &mut Self
pub fn add_render_systems<M>( &mut self, stage: RenderStage, systems: impl IntoScheduleConfigs<ScheduleSystem, M>, ) -> &mut Self
Adds render-world systems into the Render schedule under the given RenderStage set.
Sourcepub fn add_extract_systems<M>(
&mut self,
set: ExtractSet,
systems: impl IntoScheduleConfigs<ScheduleSystem, M>,
) -> &mut Self
pub fn add_extract_systems<M>( &mut self, set: ExtractSet, systems: impl IntoScheduleConfigs<ScheduleSystem, M>, ) -> &mut Self
Adds render-world systems into the dedicated ExtractSchedule under the given ExtractSet.
Foundation only installs the schedule; the legacy Self::extract_fns list keeps providing cross-world data.
Wave 2 migrates the existing extractors onto this schedule.
Sourcepub fn add_extract_fn(&mut self, f: ExtractFn) -> &mut Self
pub fn add_extract_fn(&mut self, f: ExtractFn) -> &mut Self
Appends an extract fn to Self::extract_fns.
Sourcepub fn request_threads_at_least(&mut self, n: usize) -> &mut Self
pub fn request_threads_at_least(&mut self, n: usize) -> &mut Self
Raises Self::desired_threads to n if it is currently lower (monotonic max across plugins).
Takes effect at the first Self::tick; the LUMEN_THREADS env var overrides the value.
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Runs one tick: advance the crate::tick::Tick resource, run the main schedule, then (when FrameDirty is
set) clear_extracted, every extract fn, the extract schedule, and the render schedule.
When FrameDirty is unset, returns after the main schedule; the previous frame’s extracted entities remain in
the render world for the backend’s next RedrawRequested.
Sourcepub fn commands(&mut self) -> Mut<'_, CommandReceiver>
pub fn commands(&mut self) -> Mut<'_, CommandReceiver>
Borrows the CommandReceiver resource mutably from the main world.
Sourcepub fn property<T>(&self, name: impl Into<Arc<str>>) -> Property<T>
pub fn property<T>(&self, name: impl Into<Arc<str>>) -> Property<T>
Constructs a typed crate::property_store::Property handle bound to
the global namespace. The cell is created lazily on the first set -
this helper only mints the typed key wrapper, no allocations besides
the shared Arc<str> for the name.
Equivalent to Property::<T>::new(name); lives on App so app-init
code can read more like let count = app.property::<i64>("count");
without a separate use for the prelude.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for App
impl !RefUnwindSafe for App
impl Send for App
impl Sync for App
impl Unpin for App
impl UnsafeUnpin for App
impl !UnwindSafe for App
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().