pub struct ComponentStorage { /* private fields */ }Expand description
Stores a chunk of entities and their component data of a specific data layout.
Implementations§
Source§impl ComponentStorage
impl ComponentStorage
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Gets the maximum number of entities that can be stored in the chunk.
Sourcepub fn is_allocated(&self) -> bool
pub fn is_allocated(&self) -> bool
Determines if the internal memory for this chunk has been allocated.
Sourcepub fn entities(&self) -> &[Entity]
pub fn entities(&self) -> &[Entity]
Gets a slice reference containing the IDs of all entities stored in the chunk.
Sourcepub fn components(
&self,
component_type: ComponentTypeId,
) -> Option<&ComponentResourceSet>
pub fn components( &self, component_type: ComponentTypeId, ) -> Option<&ComponentResourceSet>
Gets a component accessor for the specified component type.
Sourcepub fn swap_remove(
&mut self,
ComponentIndex: ComponentIndex,
drop: bool,
) -> Option<Entity>
pub fn swap_remove( &mut self, ComponentIndex: ComponentIndex, drop: bool, ) -> Option<Entity>
Removes an entity from the chunk by swapping it with the last entry.
Returns the ID of the entity which was swapped into the removed entity’s position.
Sourcepub fn move_entity(
&mut self,
target: &mut ComponentStorage,
index: ComponentIndex,
) -> Option<Entity>
pub fn move_entity( &mut self, target: &mut ComponentStorage, index: ComponentIndex, ) -> Option<Entity>
Moves an entity from this chunk into a target chunk, moving all compatable components into the target chunk. Any components left over will be dropped.
Returns the ID of the entity which was swapped into the removed entity’s position.
Sourcepub fn writer(&mut self) -> StorageWriter<'_>
pub fn writer(&mut self) -> StorageWriter<'_>
Gets mutable references to the internal data of the chunk.
Trait Implementations§
Source§impl Drop for ComponentStorage
impl Drop for ComponentStorage
impl Send for ComponentStorage
impl Sync for ComponentStorage
Auto Trait Implementations§
impl !Freeze for ComponentStorage
impl !RefUnwindSafe for ComponentStorage
impl Unpin for ComponentStorage
impl !UnwindSafe for ComponentStorage
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
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