
# Objective add functionality to allow propagating components to children. requested originally for `RenderLayers` but can be useful more generally. ## Solution - add `HierarchyPropagatePlugin<C, F=()>` which schedules systems to propagate components through entities matching `F` - add `Propagate<C: Component + Clone + PartialEq>` which will cause `C` to be added to all children more niche features: - add `PropagateStop<C>` which stops the propagation at this entity - add `PropagateOver<C>` which allows the propagation to continue to children, but doesn't add/remove/modify a `C` on this entity itself ## Testing see tests inline ## Notes - could happily be an out-of-repo plugin - not sure where it lives: ideally it would be in `bevy_ecs` but it requires a `Plugin` so I put it in `bevy_app`, doesn't really belong there though. - i'm not totally up-to-date on triggers and observers so possibly this could be done more cleanly, would be very happy to take review comments - perf: this is pretty cheap except for `update_reparented` which has to check the parent of every moved entity. since the entirety is opt-in i think it's acceptable but i could possibly use `(Changed<Children>, With<Inherited<C>>)` instead if it's a concern
69 lines
1.8 KiB
Rust
69 lines
1.8 KiB
Rust
#![cfg_attr(
|
|
any(docsrs, docsrs_dep),
|
|
expect(
|
|
internal_features,
|
|
reason = "rustdoc_internals is needed for fake_variadic"
|
|
)
|
|
)]
|
|
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
|
|
#![forbid(unsafe_code)]
|
|
#![doc(
|
|
html_logo_url = "https://bevy.org/assets/icon.png",
|
|
html_favicon_url = "https://bevy.org/assets/icon.png"
|
|
)]
|
|
#![no_std]
|
|
|
|
//! This crate is about everything concerning the highest-level, application layer of a Bevy app.
|
|
|
|
#[cfg(feature = "std")]
|
|
extern crate std;
|
|
|
|
extern crate alloc;
|
|
|
|
// Required to make proc macros work in bevy itself.
|
|
extern crate self as bevy_app;
|
|
|
|
mod app;
|
|
mod main_schedule;
|
|
mod panic_handler;
|
|
mod plugin;
|
|
mod plugin_group;
|
|
mod propagate;
|
|
mod schedule_runner;
|
|
mod sub_app;
|
|
mod task_pool_plugin;
|
|
#[cfg(all(any(all(unix, not(target_os = "horizon")), windows), feature = "std"))]
|
|
mod terminal_ctrl_c_handler;
|
|
|
|
#[cfg(feature = "hotpatching")]
|
|
pub mod hotpatch;
|
|
|
|
pub use app::*;
|
|
pub use main_schedule::*;
|
|
pub use panic_handler::*;
|
|
pub use plugin::*;
|
|
pub use plugin_group::*;
|
|
pub use propagate::*;
|
|
pub use schedule_runner::*;
|
|
pub use sub_app::*;
|
|
pub use task_pool_plugin::*;
|
|
#[cfg(all(any(all(unix, not(target_os = "horizon")), windows), feature = "std"))]
|
|
pub use terminal_ctrl_c_handler::*;
|
|
|
|
/// The app prelude.
|
|
///
|
|
/// This includes the most common types in this crate, re-exported for your convenience.
|
|
pub mod prelude {
|
|
#[doc(hidden)]
|
|
pub use crate::{
|
|
app::{App, AppExit},
|
|
main_schedule::{
|
|
First, FixedFirst, FixedLast, FixedPostUpdate, FixedPreUpdate, FixedUpdate, Last, Main,
|
|
PostStartup, PostUpdate, PreStartup, PreUpdate, RunFixedMainLoop,
|
|
RunFixedMainLoopSystems, SpawnScene, Startup, Update,
|
|
},
|
|
sub_app::SubApp,
|
|
Plugin, PluginGroup, TaskPoolOptions, TaskPoolPlugin,
|
|
};
|
|
}
|