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
77
78
79
80
81
82
83
84
85
86
//! Entity/component storage built on system-owned arrays.
//!
//! # Model
//!
//! * **Entity** — a generational id ([`crcbl_core::Handle<EntityMarker>`]) from
//! [`crcbl_core::Pool`]. An entity carries no data of its own.
//! * **System** — owns a dense `Vec<T>` of component data plus a sparse
//! entity→index map. Systems iterate their own arrays linearly (SoA,
//! cache-friendly). Cross-system access uses sparse lookups for cold paths.
//! * **Schedule** — an ordered sequence of systems run each tick. Each system
//! declares the [`Shared`] resources its tick reads and writes
//! ([`SystemTrait::access`]); the schedule derives the conflicts between
//! them at registration, groups the systems into stages no two systems of
//! which conflict, and, in debug builds, panics on a tick touching a
//! resource its system did not declare. Handed a `crcbl_jobs::Pool`, it
//! ticks each stage's systems across the pool's threads, with the same
//! result as running them one by one.
//! * **World** — the container: entity pool, schedule, deferred-destruction
//! queue. `World::tick()` runs the schedule then sweeps dead entities.
//! * **[`quantize`]** — how a replicated component declares its wire form:
//! fixed point, half float and smallest-three rotations, applied in
//! [`SystemTrait::replicate`] before the server compares anything.
//!
//! # Example
//!
//! ```rust
//! use crcbl_ecs::*;
//!
//! let mut world = World::new();
//!
//! // Create entities.
//! let player = world.spawn();
//! let npc = world.spawn();
//!
//! // Register a position system and attach data.
//! let mut positions = System::<(f32, f32, f32)>::new("position");
//! positions.attach(player, (0.0, 0.0, 0.0));
//! positions.attach(npc, (10.0, 0.0, 5.0));
//! world.register_system(Box::new(positions));
//!
//! // Run one tick.
//! world.tick();
//!
//! // Inspect.
//! let stats = Inspector::collect(&world);
//! assert_eq!(stats[0].name, "position");
//! assert_eq!(stats[0].entity_count, 2);
//!
//! // Despawn an entity — deferred until sweep.
//! world.despawn(npc);
//! world.tick();
//! assert_eq!(world.entity_count(), 1);
//! ```
pub use ;
pub use ComponentHash;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Shared;
pub use ;
pub use ;
pub use World;
/// Builds an [`Entity`] from raw index and generation for use in tests.
///
/// Real entities are only produced by [`World::spawn`]; this exists so unit
/// tests can fabricate handles without a full `World`.
pub