From 3e14cc06bf9c528469dc0a3c078ed37d99fe86c2 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Wed, 21 Aug 2024 15:32:37 +0200 Subject: [PATCH] better example --- examples/relations/src/main.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/relations/src/main.rs b/examples/relations/src/main.rs index 85b0098..0e1c81e 100644 --- a/examples/relations/src/main.rs +++ b/examples/relations/src/main.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; use blenvy::{BlenvyPlugin, BlueprintInfo, GameWorldTag, HideUntilReady, SpawnBlueprint}; -#[derive(Component, Reflect)] +#[derive(Component, Reflect, Debug)] #[reflect(Component)] pub struct TupleRelations(Entity); // TODO: Serialization on blender side currently is broken @@ -21,6 +21,7 @@ fn main() { .register_type::() .register_type::() .add_systems(Startup, setup_game) + .add_systems(Update, (print_names, print_tuple_relations)) .run(); } @@ -33,3 +34,15 @@ fn setup_game(mut commands: Commands) { GameWorldTag, )); } + +fn print_names(query: Query<(Entity, &Name), Added>) { + for (entity, name) in &query { + info!("[EXAMPLE] {name} is {entity}"); + } +} + +fn print_tuple_relations(query: Query<(&Name, &TupleRelations), Added>) { + for (name, r) in &query { + info!("[EXAMPLE] {name} has the relation {r:?}") + } +}