Skip to content

Commit

Permalink
Adding an archetype accessor for a slice of all entities stored within
Browse files Browse the repository at this point in the history
  • Loading branch information
recatek committed Jan 14, 2025
1 parent 54421b7 commit 2737d0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions macros/src/generate/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ fn section_archetype(archetype_data: &DataArchetype) -> TokenStream {
self.data.version()
}

#[inline(always)]
fn entities(&self) -> &[Entity<#Archetype>] {
self.data.get_slice_entities()
}

#[inline(always)]
fn create(
&mut self,
Expand Down
4 changes: 4 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ where
/// Returns the generational version of the archetype. Intended for internal use.
fn version(&self) -> ArchetypeVersion;

/// Returns a read-only slice of all entities in this archetype.
/// This slice is ordered arbitrarily and may change at later points.
fn entities(&self) -> &[Entity<Self>];

/// Creates a new entity with the given components to this archetype storage.
/// Returns a typed entity handle pointing to the new entity in the archetype.
///
Expand Down

0 comments on commit 2737d0d

Please sign in to comment.