Expand description
Entity/component storage built on system-owned arrays.
§Model
- Entity — a generational id (
crcbl_core::Handle<EntityMarker>) fromcrcbl_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
Sharedresources 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 acrcbl_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 inSystemTrait::replicatebefore the server compares anything.
§Example
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);Modules§
- quantize
- Per-component quantization for replication: how many bits each replicated field is worth on the wire.
Structs§
- Access
- The
Sharedresources a system’s tick reads and writes, by name. - Client
Inputs - The client input frames for one server tick.
- Conflict
- Two systems whose ticks touch one resource in a way that cannot overlap:
aftermust run afterbefore, as it was registered. - Debug
Ctx - Stub struct for debug-draw context.
- Entity
Marker - Zero-sized marker type for entity handles.
- Inspector
- Collects system statistics from a
World. - Schedule
- An ordered sequence of systems run each tick.
- Shared
- A named handle to state that more than one system — or a system and the
code driving the world — holds: the seam a system’s
Accessdeclaration describes. - System
- A system that owns a dense
Vec<T>of component data plus a sparse entity→index map. - System
Stats - Per-system stats collected by
Inspector::collect. - Tick
Time - One system’s measured tick cost: the last tick, and the mean over the last
TICK_TIME_WINDOWticks. - World
- The top-level ECS container.
Enums§
- Access
Error - A declaration the schedule refused, or a resource it would not register.
- Conflict
Kind - How two systems’ declarations collide on one resource.
Constants§
- TICK_
TIME_ WINDOW - How many ticks a system’s
TickTime::meanaverages over.
Traits§
- Component
Hash - Trait for component types whose byte representation is safe and deterministic to hash.
- Game
Module - Game-specific logic compiled into the binary (static binding).
- System
Trait - Object-safe trait every system in the
Schedulemust implement.
Type Aliases§
- Debug
Draw Fn - Callback type for per-system debug drawing.
- Entity
- An entity is a generational id backed by
crcbl_core::Pool<EntityMarker>. - Schedule
Clock - A clock a schedule times its systems on: shared with the pool’s workers
when the systems tick there, hence
Sync, andSendso a world that owns one can move to the thread that runs it.