chore: notes for crosshair implementation

This commit is contained in:
Robert Fry 2025-01-07 14:14:29 +00:00
parent d1230fdcad
commit 216a50ddb8
Signed by: robertfry
GPG Key ID: E89FFC8597BFE26C

View File

@ -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::<B>();
}
```
*/
pub struct CrosshairPlugin;
impl Plugin for CrosshairPlugin