Skip to main content

ComponentStorage

Struct ComponentStorage 

Source
pub struct ComponentStorage {
Show 77 fields pub Window: Column<Window>, pub GraphicsConfig: Column<GraphicsConfig>, pub Shader: Column<Shader>, pub Camera3D: Column<Camera3D>, pub FrameInput: Column<FrameInput>, pub Prop: Column<Prop>, pub RigidBody: Column<RigidBody>, pub PropBody: Column<PropBody>, pub Room: Column<Room>, pub DirectionalLight: Column<DirectionalLight>, pub PointLight: Column<PointLight>, pub SpotLight: Column<SpotLight>, pub RectAreaLight: Column<RectAreaLight>, pub ProceduralMesh: Column<ProceduralMesh>, pub Model: Column<Model>, pub Scene: Column<Scene>, pub TextLabel: Column<TextLabel>, pub HitRegion: Column<HitRegion>, pub File: Column<File>, pub BlockType: Column<BlockType>, pub VoxelChunk: Column<VoxelChunk>, pub InstancedProp: Column<InstancedProp>, pub PostProcessConfig: Column<PostProcessConfig>, pub Animation: Column<Animation>, pub SkeletonPose: Column<SkeletonPose>, pub StreamingConfig: Column<StreamingConfig>, pub VoxelWorld: Column<VoxelWorld>, pub AudioEmitter: Column<AudioEmitter>, pub Sprite: Column<Sprite>, pub KeyBinding: Column<KeyBinding>, pub Screen: Column<Screen>, pub Decal: Column<Decal>, pub VolumetricFog: Column<VolumetricFog>, pub PhysicsJoint: Column<PhysicsJoint>, pub ParticleEmitter: Column<ParticleEmitter>, pub WaterSurface: Column<WaterSurface>, pub SdfVolume: Column<SdfVolume>, pub GlassPanel: Column<GlassPanel>, pub LayoutContainer: Column<LayoutContainer>, pub PhysicsConfig: Column<PhysicsConfig>, pub FpsCounter: Column<FpsCounter>, pub StatHud: Column<StatHud>, pub ScrollPanel: Column<ScrollPanel>, pub ReflectionProbe: Column<ReflectionProbe>, pub Transform: Column<Transform>, pub PropInstance: Column<PropInstance>, pub MeshRenderer: Column<MeshRenderer>, pub ModelRenderer: Column<ModelRenderer>, pub Collider: Column<Collider>, pub BodyDynamics: Column<BodyDynamics>, pub Interactable: Column<Interactable>, pub Pickup: Column<Pickup>, pub Parent: Column<Parent>, pub Children: Column<Children>, pub SceneMember: Column<SceneMember>, pub GlobalTransform: Column<GlobalTransform>, pub RenderHandle: Column<RenderHandle>, pub Held: Column<Held>, pub Lifetime: Column<Lifetime>, pub Spawner: Column<Spawner>, pub DebugHud: Column<DebugHud>, pub AudioCue: Column<AudioCue>, pub Story: Column<Story>, pub AppConfig: Column<AppConfig>, pub AnimationGraph: Column<AnimationGraph>, pub AnimationParams: Column<AnimationParams>, pub CharacterRig: Column<CharacterRig>, pub GroundProbes: Column<GroundProbes>, pub CameraProbe: Column<CameraProbe>, pub TextInput: Column<TextInput>, pub Behavior: Column<Behavior>, pub Variables: Column<Variables>, pub TriggerVolume: Column<TriggerVolume>, pub Hidden: Column<Hidden>, pub LoadingOverlay: Column<LoadingOverlay>, pub AudioOcclusionProbe: Column<AudioOcclusionProbe>, pub CharacterShape: Column<CharacterShape>, /* private fields */
}
Expand description

One Column<T> per registered component type, the entity allocator that stamps each row’s id, the change tick stamped on every structural edit, and the join index that maps an entity to its row in each column. Field columns are the caller’s field idents, reached through the $slot trait; callers never name them directly.

Fields§

§Window: Column<Window>

The column holding every row of one registered component type.

§GraphicsConfig: Column<GraphicsConfig>

The column holding every row of one registered component type.

§Shader: Column<Shader>

The column holding every row of one registered component type.

§Camera3D: Column<Camera3D>

The column holding every row of one registered component type.

§FrameInput: Column<FrameInput>

The column holding every row of one registered component type.

§Prop: Column<Prop>

The column holding every row of one registered component type.

§RigidBody: Column<RigidBody>

The column holding every row of one registered component type.

§PropBody: Column<PropBody>

The column holding every row of one registered component type.

§Room: Column<Room>

The column holding every row of one registered component type.

§DirectionalLight: Column<DirectionalLight>

The column holding every row of one registered component type.

§PointLight: Column<PointLight>

The column holding every row of one registered component type.

§SpotLight: Column<SpotLight>

The column holding every row of one registered component type.

§RectAreaLight: Column<RectAreaLight>

The column holding every row of one registered component type.

§ProceduralMesh: Column<ProceduralMesh>

The column holding every row of one registered component type.

§Model: Column<Model>

The column holding every row of one registered component type.

§Scene: Column<Scene>

The column holding every row of one registered component type.

§TextLabel: Column<TextLabel>

The column holding every row of one registered component type.

§HitRegion: Column<HitRegion>

The column holding every row of one registered component type.

§File: Column<File>

The column holding every row of one registered component type.

§BlockType: Column<BlockType>

The column holding every row of one registered component type.

§VoxelChunk: Column<VoxelChunk>

The column holding every row of one registered component type.

§InstancedProp: Column<InstancedProp>

The column holding every row of one registered component type.

§PostProcessConfig: Column<PostProcessConfig>

The column holding every row of one registered component type.

§Animation: Column<Animation>

The column holding every row of one registered component type.

§SkeletonPose: Column<SkeletonPose>

The column holding every row of one registered component type.

§StreamingConfig: Column<StreamingConfig>

The column holding every row of one registered component type.

§VoxelWorld: Column<VoxelWorld>

The column holding every row of one registered component type.

§AudioEmitter: Column<AudioEmitter>

The column holding every row of one registered component type.

§Sprite: Column<Sprite>

The column holding every row of one registered component type.

§KeyBinding: Column<KeyBinding>

The column holding every row of one registered component type.

§Screen: Column<Screen>

The column holding every row of one registered component type.

§Decal: Column<Decal>

The column holding every row of one registered component type.

§VolumetricFog: Column<VolumetricFog>

The column holding every row of one registered component type.

§PhysicsJoint: Column<PhysicsJoint>

The column holding every row of one registered component type.

§ParticleEmitter: Column<ParticleEmitter>

The column holding every row of one registered component type.

§WaterSurface: Column<WaterSurface>

The column holding every row of one registered component type.

§SdfVolume: Column<SdfVolume>

The column holding every row of one registered component type.

§GlassPanel: Column<GlassPanel>

The column holding every row of one registered component type.

§LayoutContainer: Column<LayoutContainer>

The column holding every row of one registered component type.

§PhysicsConfig: Column<PhysicsConfig>

The column holding every row of one registered component type.

§FpsCounter: Column<FpsCounter>

The column holding every row of one registered component type.

§StatHud: Column<StatHud>

The column holding every row of one registered component type.

§ScrollPanel: Column<ScrollPanel>

The column holding every row of one registered component type.

§ReflectionProbe: Column<ReflectionProbe>

The column holding every row of one registered component type.

§Transform: Column<Transform>

The column holding every row of one registered component type.

§PropInstance: Column<PropInstance>

The column holding every row of one registered component type.

§MeshRenderer: Column<MeshRenderer>

The column holding every row of one registered component type.

§ModelRenderer: Column<ModelRenderer>

The column holding every row of one registered component type.

§Collider: Column<Collider>

The column holding every row of one registered component type.

§BodyDynamics: Column<BodyDynamics>

The column holding every row of one registered component type.

§Interactable: Column<Interactable>

The column holding every row of one registered component type.

§Pickup: Column<Pickup>

The column holding every row of one registered component type.

§Parent: Column<Parent>

The column holding every row of one registered component type.

§Children: Column<Children>

The column holding every row of one registered component type.

§SceneMember: Column<SceneMember>

The column holding every row of one registered component type.

§GlobalTransform: Column<GlobalTransform>

The column holding every row of one registered component type.

§RenderHandle: Column<RenderHandle>

The column holding every row of one registered component type.

§Held: Column<Held>

The column holding every row of one registered component type.

§Lifetime: Column<Lifetime>

The column holding every row of one registered component type.

§Spawner: Column<Spawner>

The column holding every row of one registered component type.

§DebugHud: Column<DebugHud>

The column holding every row of one registered component type.

§AudioCue: Column<AudioCue>

The column holding every row of one registered component type.

§Story: Column<Story>

The column holding every row of one registered component type.

§AppConfig: Column<AppConfig>

The column holding every row of one registered component type.

§AnimationGraph: Column<AnimationGraph>

The column holding every row of one registered component type.

§AnimationParams: Column<AnimationParams>

The column holding every row of one registered component type.

§CharacterRig: Column<CharacterRig>

The column holding every row of one registered component type.

§GroundProbes: Column<GroundProbes>

The column holding every row of one registered component type.

§CameraProbe: Column<CameraProbe>

The column holding every row of one registered component type.

§TextInput: Column<TextInput>

The column holding every row of one registered component type.

§Behavior: Column<Behavior>

The column holding every row of one registered component type.

§Variables: Column<Variables>

The column holding every row of one registered component type.

§TriggerVolume: Column<TriggerVolume>

The column holding every row of one registered component type.

§Hidden: Column<Hidden>

The column holding every row of one registered component type.

§LoadingOverlay: Column<LoadingOverlay>

The column holding every row of one registered component type.

§AudioOcclusionProbe: Column<AudioOcclusionProbe>

The column holding every row of one registered component type.

§CharacterShape: Column<CharacterShape>

The column holding every row of one registered component type.

Implementations§

Source§

impl ComponentStorage

Source

pub fn push_typed<C>(&mut self, c: C) -> Entity
where C: ComponentSlot,

Push a statically-typed component into its column, minting a fresh Entity for the new row and recording it in the join index.

Source

pub fn reserve(&mut self, component: ComponentId, additional: usize)

Pre-size a component’s column ahead of a bulk load (e.g. from a blob manifest’s per-type counts). Unknown ids are ignored.

Source

pub fn spawn(&mut self) -> Entity

Allocate a bare entity that owns no components yet. Useful for gameplay-only entities and as the target of later insert_typed.

Source

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

Whether a handle refers to a currently-live entity.

Source

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

Add component C to an existing entity. Unlike push_typed this does not mint an entity: it is how an entity comes to own more than one component. The entity must be alive and must not already have C (a second row for the same (entity, C) would desync the join).

Source

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

Remove component C from an entity (leaving the entity alive and any other components intact), returning the value if present. Swap- remove moves the column’s last row into the freed slot, so the moved row’s owner has its recorded row patched.

Source

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

Despawn an entity: swap-remove its row from every column it has, patching each moved tail row, then recycle the entity id. This is the structural-change primitive runtime despawn is built on.

Source

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

Remove and return every component of type C. Each owner loses only its C component; an owner that has no other component left is despawned so its Entity recycles. An owner that still has other components stays alive with those intact and join-reachable. The whole C column empties at once, so no per-row tail patch is needed for C; only each owner’s C entry in the join is cleared.

Source

pub fn values_mut<C>(&mut self) -> &mut [C]
where C: ComponentSlot,

Mutable slice of every component of type C, stamping the change tick because any element may be written.

Source

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

Mutable iteration over every component of type C paired with its owning entity, stamping the change tick because any element may be written. The mutable counterpart of the read-only column scan.

Source

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

The change tick of C’s column: the tick at which any C was last inserted, removed, or mutably accessed. Read-only, so it never bumps the tick itself.

Source

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

Every tick stamp of C’s column at once. A consumer that tracks rows individually needs bulk and structural alongside changed to know whether the per-row stamps still describe the whole change.

Source

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

Rows of C written since since, paired with their owning entity. Only the rows a targeted get_mut touched are reported, so this is the dirty set a per-frame pass re-examines instead of the whole column. Meaningful only while C’s bulk and structural ticks have not moved since since; past either, every row must be treated as changed.

Source

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

Borrow one entity’s component C, if it has one.

Source

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

Mutably borrow one entity’s component C, stamping that row’s change tick (and the column’s) but not the bulk tick, so changed_rows can report exactly this entity.

Source

pub fn join2<'s, A, B>( &'s self, ) -> impl Iterator<Item = (Entity, &'s A, &'s B)> + 's

Read-only join over two component types. Iterates the first type’s rows and, for each owning entity that also has the second type, yields both component refs. This is the multi-component query for read paths (the draw-list push, scene visibility): one column scan plus a join probe per row, no allocation.

Source

pub fn join3<'s, A, B, C>( &'s self, ) -> impl Iterator<Item = (Entity, &'s A, &'s B, &'s C)> + 's

Read-only join over three component types, lead on the first.

Source

pub fn len(&self) -> usize

Total number of components across all typed columns.

Source

pub fn is_empty(&self) -> bool

Whether every typed column is empty.

Source§

impl ComponentStorage

Source

pub fn push(&mut self, asset: ComponentAsset) -> Entity

Dispatch a ComponentAsset variant into its typed column via the generic typed push (which mints the Entity and stamps the tick). Returns the minted Entity so loaders can index it by name.

Source

pub fn replace(&mut self, entity: Entity, asset: ComponentAsset) -> bool

Overwrite the component the asset’s variant addresses on entity, keeping the entity and its other components, and stamping the change tick so the frame’s readers see it. false when the entity holds no component of that type.

Source

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

Every entity carrying the component with this tag, in column order. Serves the declared-query resolution in BehaviorSystem, which selects components by authored name rather than by type.

Source

pub fn component_census(&self) -> Vec<(u8, u32)>

How many components of each type are stored: one (tag, count) entry per populated type, in tag order. The debug WS snapshot reports these; nothing re-serializes stored components back to defs. Counted rather than listed per instance, so the snapshot is sized by the number of component types rather than by the world.

Trait Implementations§

Source§

impl Debug for ComponentStorage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ComponentStorage

Source§

fn default() -> ComponentStorage

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more