diff options
| author | HampusM <hampus@hampusmat.com> | 2026-06-06 18:55:07 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-06-06 19:22:04 +0200 |
| commit | 7fe8e9ea15fac647fe8655ee096a9aa5703a97c6 (patch) | |
| tree | d67f60d3275580d3963409bdc34afe8bc811453d /engine-ecs/src/entity.rs | |
| parent | e5d67bf7e36671d290b19064f58bc11616c05b8b (diff) | |
feat(engine-ecs): remove Uid kinds
Diffstat (limited to 'engine-ecs/src/entity.rs')
| -rw-r--r-- | engine-ecs/src/entity.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/engine-ecs/src/entity.rs b/engine-ecs/src/entity.rs index ad9f179..f551de1 100644 --- a/engine-ecs/src/entity.rs +++ b/engine-ecs/src/entity.rs @@ -18,7 +18,7 @@ use crate::pair::{ Pair, WithWildcard as PairWithWildcard, }; -use crate::uid::{Kind as UidKind, Uid}; +use crate::uid::Uid; use crate::{EntityComponentRef, World}; pub mod obtainer; @@ -47,12 +47,12 @@ impl<'a> Handle<'a> /// /// # Panics /// Will panic if: - /// - The component's ID is not a component ID + /// - The component's ID is pair /// - The component is mutably borrowed elsewhere #[must_use] pub fn get<ComponentT: Component>(&self) -> Option<ComponentHandle<'a, ComponentT>> { - assert_eq!(ComponentT::id().kind(), UidKind::Component); + assert!(!ComponentT::id().is_pair()); let component = self.get_matching_components(ComponentT::id()).next()?; @@ -73,14 +73,14 @@ impl<'a> Handle<'a> /// /// # Panics /// Will panic if: - /// - The component's ID is not a component ID + /// - The component's ID is a pair /// - The component is borrowed elsewhere #[must_use] pub fn get_mut<ComponentT: Component>( &self, ) -> Option<ComponentHandleMut<'a, ComponentT>> { - assert_eq!(ComponentT::id().kind(), UidKind::Component); + assert!(!ComponentT::id().is_pair()); let component = self.get_matching_components(ComponentT::id()).next()?; @@ -100,7 +100,6 @@ impl<'a> Handle<'a> /// /// # Panics /// Will panic if: - /// - The ID is not a component/pair ID /// - The component is borrowed mutably elsewhere /// - The component type is incorrect #[must_use] @@ -109,11 +108,6 @@ impl<'a> Handle<'a> id: Uid, ) -> Option<ComponentHandle<'a, ComponentDataT>> { - assert!( - matches!(id.kind(), UidKind::Component | UidKind::Pair), - "ID {id:?} is not a component/pair ID" - ); - let component = self.get_matching_components(id).next()?; Some( @@ -133,7 +127,6 @@ impl<'a> Handle<'a> /// /// # Panics /// Will panic if: - /// - The ID is not a component/pair ID /// - The component is borrowed elsewhere /// - The component type is incorrect #[must_use] @@ -142,11 +135,6 @@ impl<'a> Handle<'a> id: Uid, ) -> Option<ComponentHandleMut<'a, ComponentDataT>> { - assert!( - matches!(id.kind(), UidKind::Component | UidKind::Pair), - "ID {id:?} is not a component/pair ID" - ); - let component = self.get_matching_components(id).next()?; Some( @@ -267,7 +255,7 @@ impl Declaration pub const fn new(create_func: fn(&mut World)) -> Self { Self { - uid: LazyLock::new(|| Uid::new_unique(UidKind::Entity)), + uid: LazyLock::new(|| Uid::new_unique()), create_func, } } |
