Skip to main content

PipelineContext

Struct PipelineContext 

Source
pub struct PipelineContext<'a> {
    pub components: &'a mut ComponentStorage,
    pub blob: &'a mut dyn PayloadStore,
    pub profile: &'a mut FrameProfile,
    pub resources: &'a mut Resources,
    pub frame: FrameContext<'a>,
}
Expand description

A system’s view of the world for the duration of one step: the five things it borrows, and the accessors that reach them.

Fields§

§components: &'a mut ComponentStorage

Per-type component storage. Systems should not access this directly; use query, query_mut, drain, or push instead.

§blob: &'a mut dyn PayloadStore

Compiled-payload store. Systems use read_payload to fetch binary data, then call release_blob when done with it. A trait object so the ECS mechanism names no concrete blob store; the runtime passes BlobData.

§profile: &'a mut FrameProfile

Per-frame profiling data. World::step records each system’s CPU step time here; GraphicsSystem writes the backend RenderStats after its draw call, and StatHud reads it back to drive the on-screen HUD.

§resources: &'a mut Resources

Type-keyed engine singletons (e.g. the per-frame FrameInput snapshot), accessed via resource / resource_mut / insert_resource. Events live here too, inside a single EventStore resource that owns one Events<E> queue per event type, reached via events / events_mut.

§frame: FrameContext<'a>

Frame-scoped facilities: scratch that the frame loop reclaims wholesale. One field rather than several so what a frame offers can grow without touching every system and every construction site again.

Implementations§

Source§

impl<'a> PipelineContext<'a>

Source

pub fn query<C: ComponentSlot>(&self) -> Iter<'_, C>

Immutable iteration over all components of type C.

Source

pub fn query_with_entity<C: ComponentSlot>( &self, ) -> impl Iterator<Item = (Entity, &C)>

Iterate all components of type C paired with their owning Entity.

Source

pub fn query_mut<C: ComponentSlot>(&mut self) -> IterMut<'_, C>

Mutable iteration over all components of type C.

Source

pub fn query_mut_with_entity<C: ComponentSlot>( &mut self, ) -> impl Iterator<Item = (Entity, &mut C)>

Mutable iteration over all components of type C paired with their owning Entity (the mutable counterpart of query_with_entity), so a system can update each component and still know which entity owns it without first materializing the entity set into a Vec.

Source

pub fn changed_tick<C: ComponentSlot>(&self) -> Tick

The change tick of component type C’s column (bumped on any insert / remove / mutable access of a C). Comparing two reads across frames detects whether any C changed without scanning the column, so a per-frame pass can skip its work when nothing touched C since it last ran.

Source

pub fn column_ticks<C: ComponentSlot>(&self) -> ColumnTicks

Every tick stamp of C’s column. changed answers “did any C move”; a pass that wants to re-examine only the components that moved also needs bulk (a whole-column write, after which every row must be assumed written) and structural (a row added or removed, after which row positions and membership have moved).

Source

pub fn changed_rows<C: ComponentSlot>( &self, since: Tick, ) -> impl Iterator<Item = (Entity, &C)>

Components of type C written since since, paired with their owning entity: the dirty set a per-frame pass walks instead of the whole column. Reports only rows a targeted get_mut touched, so it is meaningful only while C’s bulk and structural ticks have not moved since since.

Source

pub fn query_slice_mut<C: ComponentSlot>(&mut self) -> &mut [C]

Mutable slice of all components of type C. Unlike query_mut this exposes the backing storage as a slice, which a system can hand to the job pool for parallel per-component work.

Source

pub fn drain<C: ComponentSlot>(&mut self) -> Vec<C>

Remove and return all components of type C, despawning each removed row’s Entity so the indices recycle.

Source

pub fn push<C: ComponentSlot>(&mut self, c: C)

Push a runtime-produced component into the matching typed column, minting a fresh Entity for it. Preferred over reaching into self.components directly.

Source

pub fn insert<C: ComponentSlot>(&mut self, entity: Entity, c: C)

Add a component to an existing entity, so an entity can own more than one component. The entity must be alive and must not already have C. Allowed dead because the caller is in the client crate (the load-time Prop decomposition); core itself has no systems.

Source

pub fn remove<C: ComponentSlot>(&mut self, entity: Entity) -> Option<C>

Remove a component from an entity, returning it if present. The entity keeps its other components. Allowed dead for the same cross-crate reason as insert (the client toggles the Held tag on pickup/drop).

Source

pub fn despawn(&mut self, entity: Entity)

Remove an entity entirely: swap-remove its row from every component column and recycle its id (a stale handle to it then reads as dead). A no-op on an already-dead or unknown entity. Allowed dead for the same cross-crate reason as insert (the client despawns entities at runtime from the GraphicsSystem).

Source

pub fn is_alive(&self, entity: Entity) -> bool

Whether an entity is still live (not despawned, matching generation). Allowed dead for the same cross-crate reason as insert (the client reaps a despawned entity’s physics body in PhysicsSystem).

Source

pub fn get<C: ComponentSlot>(&self, entity: Entity) -> Option<&C>

Borrow one entity’s component C read-only. Allowed dead for the same cross-crate reason as insert (the client reads Transform / Held by entity in the physics, camera, and audio systems).

Source

pub fn entities_with_tag(&self, tag: u8) -> &[Entity]

Every entity carrying the component with this tag. Serves the queries a Behavior declares by component name, which no type parameter can express.

Source

pub fn join2<A: ComponentSlot, B: ComponentSlot>( &self, ) -> impl Iterator<Item = (Entity, &A, &B)>

Read-only join over two component types: iterate the first type’s rows and yield both refs for every entity that also has the second. Allowed dead for the same cross-crate reason as insert.

Source

pub fn get_mut<C: ComponentSlot>(&mut self, entity: Entity) -> Option<&mut C>

Mutably borrow one entity’s component C (a propagation pass writing a single entity’s value). Allowed dead for the same cross-crate reason as insert.

Source

pub fn resource<T: Any>(&self) -> Option<&T>

Borrow the singleton resource of type T, if present.

Source

pub fn resource_mut<T: Any>(&mut self) -> Option<&mut T>

Mutably borrow the singleton resource of type T, if present.

Source

pub fn insert_resource<T: Any + Send>(&mut self, value: T) -> Option<T>

Install (or replace) the singleton resource of type T, returning the previous instance if one was present.

Source

pub fn remove_resource<T: Any>(&mut self) -> Option<T>

Withdraw the singleton resource of type T, if present.

Source

pub fn take_resource<T: Any + Send + Default>(&mut self) -> Option<T>

Take the singleton resource value of type T, leaving T::default() parked in its slot so a take/republish cycle reuses the allocation. None when the type was never inserted.

Source

pub fn events<E: 'static>(&self) -> Option<&Events<E>>

Borrow the event queue for event type E, if any events of that type have been registered.

Source

pub fn events_mut<E: Send + 'static>(&mut self) -> &mut Events<E>

Mutably borrow the event queue for event type E, creating an empty one on first access so writers and readers never miss it. All queues live in the EventStore resource, which the frame driver rotates wholesale.

Source

pub fn read_payload( &mut self, locator: &PayloadLocator, ) -> Result<&[u8], CnResult>

Read the compiled payload bytes for a locator.

Takes &mut self because an overflow blob is read from disk lazily on first access. Returns an error if the blob was released, the locator is out of range, or the on-demand load fails.

Source

pub fn release_blob(&mut self, blob_index: u32)

Release the in-memory payload for an entire blob once all systems that need it have finished (e.g. after GPU upload).

See PayloadStore::release for semantics.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PipelineContext<'a>

§

impl<'a> !Send for PipelineContext<'a>

§

impl<'a> !Sync for PipelineContext<'a>

§

impl<'a> !UnwindSafe for PipelineContext<'a>

§

impl<'a> Freeze for PipelineContext<'a>

§

impl<'a> Unpin for PipelineContext<'a>

§

impl<'a> UnsafeUnpin for PipelineContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.