diff options
Diffstat (limited to 'engine-ecs/src/lib.rs')
| -rw-r--r-- | engine-ecs/src/lib.rs | 32 |
1 files changed, 13 insertions, 19 deletions
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<Comps>(&mut self, components: Comps) -> Uid - where - Comps: ComponentSequence, + pub fn spawn<BundleT: Bundle>(&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<Comps>( + pub fn spawn_named<BundleT: Bundle>( &mut self, name: impl Into<Cow<'static, str>>, - 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<Comps>(&mut self, entity_uid: Uid, components: Comps) - where - Comps: ComponentSequence, + pub fn spawn_with_uid<BundleT: Bundle>(&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<Comps>( + pub fn spawn_named_with_uid<BundleT: Bundle>( &mut self, entity_uid: Uid, name: impl Into<Cow<'static, str>>, - 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() |
