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 ComponentStoragePer-type component storage. Systems should not access this directly;
use query, query_mut, drain, or push instead.
blob: &'a mut dyn PayloadStoreCompiled-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 FrameProfilePer-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 ResourcesType-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>
impl<'a> PipelineContext<'a>
Sourcepub fn query<C>(&self) -> Iter<'_, C> ⓘwhere
C: ComponentSlot,
pub fn query<C>(&self) -> Iter<'_, C> ⓘwhere
C: ComponentSlot,
Immutable iteration over all components of type C.
Sourcepub fn query_with_entity<C>(&self) -> impl Iterator<Item = (Entity, &C)>where
C: ComponentSlot,
pub fn query_with_entity<C>(&self) -> impl Iterator<Item = (Entity, &C)>where
C: ComponentSlot,
Iterate all components of type C paired with their owning Entity.
Sourcepub fn query_mut<C>(&mut self) -> IterMut<'_, C> ⓘwhere
C: ComponentSlot,
pub fn query_mut<C>(&mut self) -> IterMut<'_, C> ⓘwhere
C: ComponentSlot,
Mutable iteration over all components of type C.
Sourcepub fn query_mut_with_entity<C>(
&mut self,
) -> impl Iterator<Item = (Entity, &mut C)>where
C: ComponentSlot,
pub fn query_mut_with_entity<C>(
&mut self,
) -> impl Iterator<Item = (Entity, &mut C)>where
C: ComponentSlot,
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.
Sourcepub fn changed_tick<C>(&self) -> Tickwhere
C: ComponentSlot,
pub fn changed_tick<C>(&self) -> Tickwhere
C: ComponentSlot,
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.
Sourcepub fn column_ticks<C>(&self) -> ColumnTickswhere
C: ComponentSlot,
pub fn column_ticks<C>(&self) -> ColumnTickswhere
C: ComponentSlot,
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).
Sourcepub fn changed_rows<C>(&self, since: Tick) -> impl Iterator<Item = (Entity, &C)>where
C: ComponentSlot,
pub fn changed_rows<C>(&self, since: Tick) -> impl Iterator<Item = (Entity, &C)>where
C: ComponentSlot,
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.
Sourcepub fn query_slice_mut<C>(&mut self) -> &mut [C]where
C: ComponentSlot,
pub fn query_slice_mut<C>(&mut self) -> &mut [C]where
C: ComponentSlot,
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.
Sourcepub fn drain<C>(&mut self) -> Vec<C>where
C: ComponentSlot,
pub fn drain<C>(&mut self) -> Vec<C>where
C: ComponentSlot,
Remove and return all components of type C, despawning each removed row’s Entity so the indices recycle.
Sourcepub fn push<C>(&mut self, c: C)where
C: ComponentSlot,
pub fn push<C>(&mut self, c: C)where
C: ComponentSlot,
Push a runtime-produced component into the matching typed column,
minting a fresh Entity for it. Preferred over reaching into
self.components directly.
Sourcepub fn insert<C>(&mut self, entity: Entity, c: C)where
C: ComponentSlot,
pub fn insert<C>(&mut self, entity: Entity, c: C)where
C: ComponentSlot,
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.
Sourcepub fn remove<C>(&mut self, entity: Entity) -> Option<C>where
C: ComponentSlot,
pub fn remove<C>(&mut self, entity: Entity) -> Option<C>where
C: ComponentSlot,
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).
Sourcepub fn despawn(&mut self, entity: Entity)
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).
Sourcepub fn is_alive(&self, entity: Entity) -> bool
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).
Sourcepub fn get<C>(&self, entity: Entity) -> Option<&C>where
C: ComponentSlot,
pub fn get<C>(&self, entity: Entity) -> Option<&C>where
C: ComponentSlot,
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).
Sourcepub fn entities_with_tag(&self, tag: u8) -> &[Entity]
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.
Sourcepub fn join2<A, B>(&self) -> impl Iterator<Item = (Entity, &A, &B)>where
A: ComponentSlot,
B: ComponentSlot,
pub fn join2<A, B>(&self) -> impl Iterator<Item = (Entity, &A, &B)>where
A: ComponentSlot,
B: ComponentSlot,
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.
Sourcepub fn get_mut<C>(&mut self, entity: Entity) -> Option<&mut C>where
C: ComponentSlot,
pub fn get_mut<C>(&mut self, entity: Entity) -> Option<&mut C>where
C: ComponentSlot,
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.
Sourcepub fn resource<T>(&self) -> Option<&T>where
T: Any,
pub fn resource<T>(&self) -> Option<&T>where
T: Any,
Borrow the singleton resource of type T, if present.
Sourcepub fn resource_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
pub fn resource_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
Mutably borrow the singleton resource of type T, if present.
Sourcepub fn insert_resource<T>(&mut self, value: T) -> Option<T>
pub fn insert_resource<T>(&mut self, value: T) -> Option<T>
Install (or replace) the singleton resource of type T, returning the previous instance if one was present.
Sourcepub fn remove_resource<T>(&mut self) -> Option<T>where
T: Any,
pub fn remove_resource<T>(&mut self) -> Option<T>where
T: Any,
Withdraw the singleton resource of type T, if present.
Sourcepub fn take_resource<T>(&mut self) -> Option<T>
pub fn take_resource<T>(&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.
Sourcepub fn events<E>(&self) -> Option<&Events<E>>where
E: 'static,
pub fn events<E>(&self) -> Option<&Events<E>>where
E: 'static,
Borrow the event queue for event type E, if any events of that type have been registered.
Sourcepub fn events_mut<E>(&mut self) -> &mut Events<E>where
E: Send + 'static,
pub fn events_mut<E>(&mut self) -> &mut Events<E>where
E: Send + 'static,
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.
Sourcepub fn read_payload(
&mut self,
locator: &PayloadLocator,
) -> Result<&[u8], CnResult>
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.
Sourcepub fn release_blob(&mut self, blob_index: u32)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more