use crate::z_ignore_test_common::*;
use flecs_ecs::prelude::*;
#[derive(Debug, Component)]
pub struct Position {
pub x: f32,
pub y: f32,
}
#[derive(Debug, Component)]
pub struct Velocity {
pub x: f32,
pub y: f32,
}
fn main() {
let world = World::new();
world
.observer::<flecs::OnSet, (&Position, &Velocity)>()
.each_iter(|it, index, (pos, vel)| {
println!(
" - {}: {}: {}: p: {{ {}, {} }}, v: {{ {}, {} }}",
it.event().name(),
it.event_id().to_str(),
it.entity(index).name(),
pos.x,
pos.y,
vel.x,
vel.y
);
});
let entity = world.entity_named("e").set(Position { x: 10.0, y: 20.0 });
entity.set(Velocity { x: 1.0, y: 2.0 });
}
#[cfg(feature = "flecs_nightly_tests")]
#[test]
fn test() {
let output_capture = OutputCapture::capture().unwrap();
main();
output_capture.test("observer_two_components".to_string());
}