Skip to main content

Module ecs

Module ecs 

Source
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 T was added.
Archetype
A table of entities that share exactly the same component type set.
ArchetypeId
Unique index into World::archetypes.
Changed
Change-detection filter: component T was mutably accessed.
Commands
Deferred world mutations applied at end-of-frame.
Entity
A lightweight generational handle identifying a live entity.
EntityMut
Read-write view into a single entity’s components.
EntityRef
Read-only view into a single entity’s components.
EventCursor
An independent read cursor into Events<E>.
EventReader
Read handle for Events<E> with its own cursor.
EventWriter
Write handle for Events<E>.
Events
Double-buffered typed event queue.
FunctionSystem
A system wrapping a plain closure.
Local
System-local persistent state.
OptionRead
Fetch marker: yields Option<&'w T> (entity need not have T).
QueryIter
Iterator over archetypes matching query Q and filter F.
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.
SystemLabel
A human-readable system identifier.
With
Requires component T to be present (not fetched).
Without
Requires component T to 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 + Clone type to use it as a component.
QueryFilter
Archetype-level filter for queries.
System
A unit of logic operating on the World.
SystemParam
Types extractable from a World as system parameters.
WorldQuery
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 C added after tick since.
query_changed
Entities with C changed after tick since.
was_added
true if component C on entity was added after tick since.
was_changed
true if component C on entity was changed after tick since.

Type Aliases§

RunCondition
Boxed run-condition closure.