diff --git a/src/ui/crosshair.rs b/src/ui/crosshair.rs index 8fdf829..c602711 100644 --- a/src/ui/crosshair.rs +++ b/src/ui/crosshair.rs @@ -5,6 +5,29 @@ use bevy::prelude::*; // For now, we'll just draw a crosshair in the center of the screen. // This causes a lot of warnings without a camera! +/* +In bevy 0.15.x, you can automatically insert components based on other components using required components +https://docs.rs/bevy/latest/bevy/ecs/component/trait.Component.html#required-components + +For removal, I would implement it using component hooks +https://docs.rs/bevy/latest/bevy/ecs/component/struct.ComponentHooks.html + +An example where adding or removing A adds or removes B: +```rust +#[derive(Component)] +pub struct B; + +#[derive(Component)] +#[require(B)] +#[component(on_remove = remove_B)] +pub struct A; + +fn remove_B(world : DefferedWorld, entity : Entity, _id : ComponentId) { + world.commands().entity(entity).remove::(); +} +``` +*/ + pub struct CrosshairPlugin; impl Plugin for CrosshairPlugin