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,
}
#[derive(Component)]
pub struct Walking;
fn main() {
let world = World::new();
let bob = world
.entity_named("Bob")
.set(Position { x: 10.0, y: 20.0 })
.add(Walking);
bob.get::<Option<&Position>>(|pos| {
if let Some(pos) = pos {
println!("Bob's position: {pos:?}");
}
});
bob.set(Position { x: 20.0, y: 30.0 });
let alice = world
.entity_named("Alice")
.set(Position { x: 10.0, y: 20.0 });
alice.add(Walking);
println!("[{}]", alice.archetype());
alice.remove(Walking);
world.each_entity::<&Position>(|entity, pos| {
println!("{} has {:?}", entity.name(), pos);
});
}
#[cfg(feature = "flecs_nightly_tests")]
#[test]
fn test() {
let output_capture = OutputCapture::capture().unwrap();
main();
output_capture.test("entity_basics".to_string());
}