summaryrefslogtreecommitdiff
path: root/engine-ecs/src/entity.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine-ecs/src/entity.rs')
-rw-r--r--engine-ecs/src/entity.rs24
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,
}
}