Expand description
§Entity Component System (ECS)
A standalone archetype-based ECS for the Proof Engine. All types live in this single module — no external submodules required.
§Design
Components are grouped by type signature into Archetype tables for
cache-friendly iteration. Fetch markers (Read<T>, Write<T>,
OptionRead<T>) carry no lifetimes so they satisfy WorldQuery: 'static.
§Quick start
ⓘ
use proof_engine::ecs::*;
#[derive(Clone)] struct Pos(f32, f32);
impl Component for Pos {}
let mut world = World::new();
let e = world.spawn(Pos(0.0, 0.0));
for pos in world.query::<Read<Pos>, ()>() { let _ = pos.0; }Modules§
- prelude
- Common ECS re-exports.
Structs§
- Added
- Change-detection filter: component
Twas added. - Archetype
- A table of entities that share exactly the same component type set.
- Archetype
Id - Unique index into
World::archetypes. - Changed
- Change-detection filter: component
Twas mutably accessed. - Commands
- Deferred world mutations applied at end-of-frame.
- Entity
- A lightweight generational handle identifying a live entity.
- Entity
Mut - Read-write view into a single entity’s components.
- Entity
Ref - Read-only view into a single entity’s components.
- Event
Cursor - An independent read cursor into
Events<E>. - Event
Reader - Read handle for
Events<E>with its own cursor. - Event
Writer - Write handle for
Events<E>. - Events
- Double-buffered typed event queue.
- Function
System - A system wrapping a plain closure.
- Local
- System-local persistent state.
- Option
Read - Fetch marker: yields
Option<&'w T>(entity need not have T). - Query
Iter - Iterator over archetypes matching query
Qand filterF. - Read
- Fetch marker: yields
&'w T. - Res
- Immutable resource borrow.
- ResMut
- Mutable resource borrow.
- Resources
- Type-map of global singleton resources.
- Schedule
- Ordered list of systems with optional labels and run conditions.
- System
Label - A human-readable system identifier.
- With
- Requires component
Tto be present (not fetched). - Without
- Requires component
Tto be absent. - World
- The central ECS container: archetypes, entity allocator, resources, events.
- Write
- Fetch marker: yields
&'w mut T.
Traits§
- Bundle
- A heterogeneous set of components spawned together.
- Component
- Marker trait for ECS components. Implement this for any
'static + Send + Sync + Clonetype to use it as a component. - Query
Filter - Archetype-level filter for queries.
- System
- A unit of logic operating on the
World. - System
Param - Types extractable from a
Worldas system parameters. - World
Query - Trait for types that describe how to fetch data from an archetype row.
Functions§
- into_
system - Wraps a closure as a boxed
System. - query_
added - Entities with
Cadded after ticksince. - query_
changed - Entities with
Cchanged after ticksince. - was_
added trueif componentConentitywas added after ticksince.- was_
changed trueif componentConentitywas changed after ticksince.
Type Aliases§
- RunCondition
- Boxed run-condition closure.