#![allow(unused_imports, unused_variables, dead_code, non_snake_case, path_statements, unreachable_code, unused_mut,clippy::print_stdout)]
#![cfg_attr(rustfmt, rustfmt_skip)]
use crate::common_test::*;
#[test]
fn flecs_quickstart_concepts_world_01() {
let world = World::new();
}
#[test]
fn flecs_quickstart_concepts_entity_02() {
let world = World::new();
let e = world.entity();
e.is_alive();
e.destruct();
e.is_alive(); }
#[test]
fn flecs_quickstart_concepts_entity_03() {
let world = World::new();
let world = World::new();
let e = world.entity_named("bob");
println!("Entity name: {}", e.name());
}
#[test]
fn flecs_quickstart_concepts_entity_04() {
let world = World::new();
world.entity_named("bob");
let e = world.lookup("bob");
let e = world.try_lookup("bob");
}
#[test]
fn flecs_quickstart_concepts_component_05() {
#[derive(Default, Component)]
pub struct Velocity {
pub x: f32,
pub y: f32,
}
let world = World::new();
let e = world.entity();
e.add(Velocity::id());
e.set(Position { x: 10.0, y: 20.0 })
.set(Velocity { x: 1.0, y: 2.0 });
e.get::<&Position>(|p| {
println!("Position: ({}, {})", p.x, p.y);
});
e.remove(Position::id());
}
#[test]
fn flecs_quickstart_concepts_component_06() {
let world = World::new();
let pos_e = world.entity_from::<Position>();
println!("Name: {}", pos_e.name());
pos_e.add(Serializable::id());
}
#[test]
fn flecs_quickstart_concepts_component_07() {
let world = World::new();
let pos_e = world.entity_from::<Position>();
pos_e.get::<&flecs::Component>(|c| {
println!("Component size: {}", c.size);
});
}
#[test]
fn flecs_quickstart_concepts_tag_08() {
let world = World::new();
#[derive(Component)]
struct Enemy;
let e = world.entity().add(Enemy);
e.has(Enemy::id());
e.remove(Enemy::id());
e.has(Enemy::id());
let enemy = world.entity();
let e = world.entity().add(enemy);
e.has(enemy);
e.remove(enemy);
e.has(enemy); }
#[test]
fn flecs_quickstart_concepts_pair_09() {
let world = World::new();
#[derive(Component)]
struct Likes;
let bob = world.entity();
let alice = world.entity();
bob.add((Likes::id(), alice.id())); alice.add((Likes::id(), bob.id())); bob.has((Likes::id(), alice.id()));
bob.remove((Likes::id(), alice.id()));
bob.has((Likes::id(), alice.id())); }
#[test]
fn flecs_quickstart_concepts_pair_10() {
let world = World::new();
let bob = world.entity();
let id = world.id_from((Likes::id(), bob.id()));
}
#[test]
fn flecs_quickstart_concepts_pair_11() {
let world = World::new();
let id = world.id_view_from((Likes::id(), Apples::id()));
if id.is_pair() {
let relationship = id.first_id();
let target = id.second_id();
}
}
#[test]
fn flecs_quickstart_concepts_pair_12() {
let world = World::new();
let eats = world.entity();
let apples = world.entity();
let pears = world.entity();
let grows = world.entity();
let bob = world.entity();
bob.add((eats, apples));
bob.add((eats, pears));
bob.add((grows, pears));
bob.has((eats, apples)); bob.has((eats, pears)); bob.has((grows, pears)); }
#[test]
fn flecs_quickstart_concepts_pair_13() {
let world = World::new();
let bob = world.entity();
let alice = world.entity().add((Likes,bob));
let o = alice.target(Likes,0); }
#[test]
fn flecs_quickstart_concepts_hierarchies_14() {
let world = World::new();
let parent = world.entity();
let child = world.entity().child_of(parent);
parent.destruct();
}
#[test]
fn flecs_quickstart_concepts_hierarchies_15() {
let world = World::new();
let parent = world.entity_named("parent");
let child = world.entity_named("child").child_of(parent);
println!("Child path: {}", child.path().unwrap());
world.lookup("parent::child"); parent.lookup("child"); }
#[test]
fn flecs_quickstart_concepts_hierarchies_16() {
let world = World::new();
let q = world
.query::<(&Position, &mut Position)>()
.term_at(1)
.parent()
.cascade()
.build();
q.each(|(p, p_parent)| {
});
}
#[test]
fn flecs_quickstart_concepts_type_17() {
let world = World::new();
let e = world.entity().add(Position::id()).add(Velocity::id());
println!("Components: {}", e.archetype().to_string().unwrap()); }
#[test]
fn flecs_quickstart_concepts_type_18() {
let world = World::new();
let e = world.entity().add(Position::id()).add(Velocity::id());
e.each_component(|id| {
if id == world.component_id::<Position>() {
}
});
}
#[test]
fn flecs_quickstart_concepts_singleton_19() {
let world = World::new();
world.set(Gravity { value: 9.8 });
world.get::<&Gravity>(|g| {
println!("Gravity: {}", g.value);
});
}
#[test]
fn flecs_quickstart_concepts_singleton_20() {
let world = World::new();
let grav_e = world.entity_from::<Gravity>();
grav_e.set(Gravity { value: 9.8 });
grav_e.get::<&Gravity>(|g| {
println!("Gravity: {}", g.value);
});
}
#[test]
fn flecs_quickstart_concepts_singleton_21() {
let world = World::new();
world
.query::<(&Velocity, &Gravity)>()
.build();
}
#[test]
fn flecs_quickstart_concepts_query_22() {
let world = World::new();
world.each::<(&mut Position, &Velocity)>(|(p, v)| {
p.x += v.x;
p.y += v.y;
});
let parent = world.entity();
let q = world
.query::<&Position>()
.with((flecs::ChildOf::ID, parent))
.build();
q.each_entity(|e, p| {
println!("{}: ({}, {})", e.name(), p.x, p.y);
});
q.run(|mut it| {
while it.next() {
let p = it.field::<Position>(0);
for i in it.iter() {
println!("{}: ({}, {})", it.entity(i).name(), p[i].x, p[i].y);
}
}
});
}
#[test]
fn flecs_quickstart_concepts_query_23() {
let world = World::new();
let q = world
.query::<()>()
.with((flecs::ChildOf, flecs::Wildcard))
.with(Position::id())
.set_oper(OperKind::Not)
.build();
}
#[test]
fn flecs_quickstart_concepts_system_24() {
let world = World::new();
let move_sys = world
.system::<(&mut Position, &Velocity)>()
.each_iter(|it, i, (p, v)| {
p.x += v.x * it.delta_time();
p.y += v.y * it.delta_time();
});
move_sys.run();
}
#[test]
fn flecs_quickstart_concepts_system_25() {
let world = World::new();
let move_sys = world.system::<(&mut Position, &Velocity)>().each(|(p, v)| {});
println!("System: {}", move_sys.name());
move_sys.add(flecs::pipeline::OnUpdate);
move_sys.destruct();
}
#[test]
fn flecs_quickstart_concepts_pipeline_26() {
flecs::pipeline::OnLoad;
flecs::pipeline::PostLoad;
flecs::pipeline::PreUpdate;
flecs::pipeline::OnUpdate;
flecs::pipeline::OnValidate;
flecs::pipeline::PostUpdate;
flecs::pipeline::PreStore;
flecs::pipeline::OnStore;
}
#[test]
fn flecs_quickstart_concepts_pipeline_27() {
let world = World::new();
world
.system_named::<(&mut Position, &Velocity)>("Move")
.kind(flecs::pipeline::OnUpdate)
.each(|(p, v)| {});
world
.system_named::<(&mut Position, &Transform)>("Transform")
.kind(flecs::pipeline::PostUpdate)
.each(|(p, t)| {});
world
.system_named::<(&Transform, &mut Mesh)>("Render")
.kind(flecs::pipeline::OnStore)
.each(|(t, m)| {});
world.progress();
}
#[test]
fn flecs_quickstart_concepts_pipeline_28() {
let world = World::new();
let move_sys = world.system::<(&mut Position, &Velocity)>().each(|(p, v)| {});
move_sys.add(flecs::pipeline::OnUpdate);
move_sys.remove(flecs::pipeline::PostUpdate);
}
#[test]
fn flecs_quickstart_concepts_observer_29() {
let world = World::new();
world
.observer_named::<flecs::OnSet, (&Position, &Velocity)>("OnSetPosition")
.each(|(p, v)| {});
let e = world.entity(); e.set(Position { x: 10.0, y: 20.0 }); e.set(Velocity { x: 1.0, y: 2.0 }); e.set(Position { x: 30.0, y: 40.0 }); }
#[test]
fn flecs_quickstart_concepts_module_30() {
let world = World::new();
#[derive(Component)]
struct MyModule;
impl Module for MyModule {
fn module(world: &World) {
world.module::<MyModule>("MyModule");
}
}
world.import::<MyModule>();
}