1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! ECS-style query builder for iterating entities by component composition.
//!
//! # Audience
//!
//! This module is the **extension-author surface**: the generic
//! builder for iterating over arbitrary component combinations,
//! including [`Ext<T>`](crate::query::Ext) game-defined components.
//! Use it when:
//!
//! - You're filtering on a combination of components
//! ([`With`](crate::query::With) / [`Without`](crate::query::Without)
//! / multiple `&T` slots) — e.g. "all riders with a `VipTag`
//! extension and a position".
//! - You're operating on game-defined [`Ext<T>`](crate::query::Ext)
//! components that don't have hand-written iterators on
//! [`World`](crate::world::World).
//!
//! Core's per-tick hot paths intentionally use the typed
//! [`World::iter_riders`](crate::world::World::iter_riders),
//! [`World::iter_elevators`](crate::world::World::iter_elevators),
//! [`World::iter_stops`](crate::world::World::iter_stops), etc. —
//! direct accessors over the `SoA` storage that skip the generic
//! dispatch layer. The builder is for the cases those don't cover.
//! `query_bench` shows the builder is fast (linear in entity count
//! with a small constant), but for known component types the typed
//! accessor is still preferred.
//!
//! # Examples
//!
//! ```
//! use elevator_core::components::{Position, Rider, Route};
//! use elevator_core::prelude::*;
//! use elevator_core::query::{Ext, With, Without};
//! use elevator_core::world::ExtKey;
//!
//! use serde::{Serialize, Deserialize};
//!
//! #[derive(Debug, Clone, Serialize, Deserialize)]
//! struct VipTag { level: u32 }
//!
//! let mut sim = SimulationBuilder::demo().build().unwrap();
//! let rider_eid = sim.spawn_rider(StopId(0), StopId(1), 75.0).unwrap();
//!
//! // Attach an extension component.
//! sim.world_mut().insert_ext(rider_eid.entity(), VipTag { level: 5 }, ExtKey::from_type_name());
//!
//! let world = sim.world();
//!
//! // All riders with a position
//! for (id, rider, pos) in world.query::<(EntityId, &Rider, &Position)>().iter() {
//! println!("{id:?}: phase={:?} at {}", rider.phase(), pos.value());
//! }
//!
//! // Entities with Position but without Route
//! for (id, pos) in world.query::<(EntityId, &Position)>()
//! .without::<Route>()
//! .iter()
//! {
//! println!("{id:?} at {}", pos.value());
//! }
//!
//! // Extension components (cloned)
//! for (id, vip) in world.query::<(EntityId, &Ext<VipTag>)>().iter() {
//! println!("VIP rider {id:?}: level {}", vip.level);
//! }
//! ```
pub
pub use ;
pub use ;
pub use ;