Last active
January 17, 2021 16:29
-
-
Save Ardakaniz/5b1db9b11c58bf9f996f38e0dce0efe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
#[derive(Default)] | |
struct A; | |
#[derive(Default, Bundle)] | |
struct B { a: A } | |
#[derive(Default, Bundle)] | |
struct C { b: B } | |
fn sys(query_a: Query<&A>, query_b: Query<&B>) { | |
assert!(query_a.iter().count() == 2); | |
assert!(query_b.iter().count() == 2); | |
} | |
fn startup(commands: &mut Commands) { | |
commands.spawn(C::default()).spawn(B::default()).spawn((A::default(), )); | |
} | |
fn main() { | |
App::build().add_startup_system(startup.system()).add_system(sys.system()).run(); | |
} | |
// Resulting in: | |
// thread 'TaskPool (2)' panicked at 'assertion failed: query_b.iter().count() == 2', src/main.rs:12:3 | |
// Expected result: | |
// first assert asserting | |
// second one not asserting | |
// Because entity with C also have B thus also A | |
// Entity B also have A | |
// + another A entity | |
// == 3 entity having A; 2 entity having B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment