diff options
| author | HampusM <hampus@hampusmat.com> | 2026-07-08 23:19:06 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-07-08 23:19:06 +0200 |
| commit | 213e4cfc698f0e0f9fcfbe43cf8c49f8f331e699 (patch) | |
| tree | 666b38f087985fa0ed6d85f3d046760b16666365 /engine-ecs/src/entity.rs | |
| parent | 05063e79465a33eb156c25edf8193fd77ba24314 (diff) | |
refactor(engine-ecs): rename entity creation fns to use 'spawn' terminology
Diffstat (limited to 'engine-ecs/src/entity.rs')
| -rw-r--r-- | engine-ecs/src/entity.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/engine-ecs/src/entity.rs b/engine-ecs/src/entity.rs index 9ef9da0..b9829e1 100644 --- a/engine-ecs/src/entity.rs +++ b/engine-ecs/src/entity.rs @@ -3,16 +3,12 @@ use std::borrow::Cow; use std::ops::Deref; use std::sync::LazyLock; -use crate::Component; use crate::component::storage::archetype::{ Archetype, Entity as ArchetypeEntity, MatchingComponentIter as ArchetypeMatchingComponentIter, }; -use crate::component::{ - Handle as ComponentHandle, - HandleMut as ComponentHandleMut, -}; +use crate::component::{Handle as ComponentHandle, HandleMut as ComponentHandleMut}; use crate::pair::{ ComponentOrWildcard, MultipleWithWildcard as PairMultipleWithWildcard, @@ -20,7 +16,7 @@ use crate::pair::{ WithWildcard as PairWithWildcard, }; use crate::uid::Uid; -use crate::{EntityComponentRef, World}; +use crate::{Component, EntityComponentRef, World}; pub mod obtainer; @@ -288,22 +284,22 @@ impl<'a> Iterator for MatchingComponentIter<'a> pub struct Declaration { uid: LazyLock<Uid>, - create_func: fn(&mut World), + spawn_func: fn(&mut World), } impl Declaration { - pub(crate) fn create(&self, world: &mut World) + pub(crate) fn spawn(&self, world: &mut World) { - (self.create_func)(world); + (self.spawn_func)(world); } #[doc(hidden)] - pub const fn new(create_func: fn(&mut World)) -> Self + pub const fn new(spawn_func: fn(&mut World)) -> Self { Self { uid: LazyLock::new(|| Uid::new_unique()), - create_func, + spawn_func, } } } @@ -324,7 +320,7 @@ macro_rules! declare_entity { ($visibility: vis $ident: ident, $components: expr) => { $visibility static $ident: $crate::entity::Declaration = $crate::entity::Declaration::new(|world| { - world.create_entity_with_uid(*$ident, $components); + world.spawn_with_uid(*$ident, $components); }); } } @@ -333,5 +329,5 @@ macro_rules! declare_entity { #[derive(Debug, Clone, Component)] pub struct Name { - pub name: Cow<'static, str> + pub name: Cow<'static, str>, } |
