From fd28c16e6455aeff206543b1d1b6655729aaed07 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 20 Sep 2026 19:05:03 +0200 Subject: refactor(engine-ecs): move & rename component::Sequence to bundle::Bundle --- engine-ecs/src/lib.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'engine-ecs/src/lib.rs') diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs index 450940a..53e49df 100644 --- a/engine-ecs/src/lib.rs +++ b/engine-ecs/src/lib.rs @@ -9,6 +9,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::time::Duration; use crate::actions::Action; +use crate::bundle::Bundle; use crate::component::storage::archetype::EntityComponent as ArchetypeEntityComponent; use crate::component::storage::{ EntityAlreadyExistsError, @@ -20,7 +21,6 @@ use crate::component::{ Info as ComponentInfo, IntoParts as IntoComponentParts, Parts as ComponentParts, - Sequence as ComponentSequence, }; use crate::entity::{ Declaration as EntityDeclaration, @@ -66,6 +66,7 @@ use crate::system::{ use crate::uid::Uid; pub mod actions; +pub mod bundle; pub mod component; pub mod entity; pub mod error; @@ -137,13 +138,11 @@ impl World /// Creates a entity with the given components. A new unique [`Uid`] will be generated /// for this entity. - pub fn spawn(&mut self, components: Comps) -> Uid - where - Comps: ComponentSequence, + pub fn spawn(&mut self, bundle: BundleT) -> Uid { let entity_uid = Uid::new_unique(); - self.spawn_with_uid(entity_uid, components); + self.spawn_with_uid(entity_uid, bundle); entity_uid } @@ -153,17 +152,15 @@ impl World /// /// In addition to the given components, the entity will have a [`EntityName`] /// component containing `name`. - pub fn spawn_named( + pub fn spawn_named( &mut self, name: impl Into>, - components: Comps, + bundle: BundleT, ) -> Uid - where - Comps: ComponentSequence, { let entity_uid = Uid::new_unique(); - self.spawn_named_with_uid(entity_uid, name, components); + self.spawn_named_with_uid(entity_uid, name, bundle); entity_uid } @@ -171,11 +168,9 @@ impl World /// Creates a entity with the given components. The entity will have the specified /// [`Uid`]. #[tracing::instrument(skip_all)] - pub fn spawn_with_uid(&mut self, entity_uid: Uid, components: Comps) - where - Comps: ComponentSequence, + pub fn spawn_with_uid(&mut self, entity_uid: Uid, bundle: BundleT) { - let components_parts = components.into_parts_array(); + let components_parts = bundle.into_parts_array(); if let Some(comp_parts) = components_parts .as_ref() @@ -197,15 +192,14 @@ impl World /// In addition to the given components, the entity will have a [`EntityName`] /// component containing `name`. #[tracing::instrument(skip_all)] - pub fn spawn_named_with_uid( + pub fn spawn_named_with_uid( &mut self, entity_uid: Uid, name: impl Into>, - components: Comps, - ) where - Comps: ComponentSequence, + bundle: BundleT, + ) { - let components_parts = components.into_parts_array(); + let components_parts = bundle.into_parts_array(); if let Some(comp_parts) = components_parts .as_ref() -- cgit v1.2.3-18-g5258