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/component/storage | |
| parent | e5d67bf7e36671d290b19064f58bc11616c05b8b (diff) | |
feat(engine-ecs): remove Uid kinds
Diffstat (limited to 'engine-ecs/src/component/storage')
| -rw-r--r-- | engine-ecs/src/component/storage/archetype.rs | 39 | ||||
| -rw-r--r-- | engine-ecs/src/component/storage/graph.rs | 7 |
2 files changed, 10 insertions, 36 deletions
diff --git a/engine-ecs/src/component/storage/archetype.rs b/engine-ecs/src/component/storage/archetype.rs index a7fe7ed..c5cce10 100644 --- a/engine-ecs/src/component/storage/archetype.rs +++ b/engine-ecs/src/component/storage/archetype.rs @@ -8,7 +8,7 @@ use std::slice::Iter as SliceIter; use hashbrown::HashMap; use crate::lock::Lock; -use crate::uid::{Kind as UidKind, Uid}; +use crate::uid::Uid; use crate::util::{Either, HashMapExt}; #[derive(Debug)] @@ -77,8 +77,6 @@ impl Archetype pub fn remove_entity(&mut self, entity_uid: Uid) -> Option<Entity> { - //debug_assert_eq!(entity_uid.kind(), UidKind::Entity); - let entity_index = self.entity_index_lookup.remove(&entity_uid)?; if self.entities.len() == 1 { @@ -124,14 +122,7 @@ impl Archetype component_id: Uid, ) -> MatchingComponentIter<'_> { - assert!( - component_id.kind() == UidKind::Component - || component_id.kind() == UidKind::Pair - ); - - if component_id.kind() == UidKind::Pair - && component_id.target_component() == Uid::wildcard() - { + if component_id.is_pair() && component_id.target() == Uid::wildcard() { return MatchingComponentIter { inner: Either::A( self.component_ids @@ -140,7 +131,7 @@ impl Archetype .zip(std::iter::repeat_n(component_id, self.component_ids.len())) .filter( (|((_, other_comp_id), component_id)| { - other_comp_id.kind() == UidKind::Pair + other_comp_id.is_pair() && other_comp_id.has_same_relation_as(*component_id) }) as MatchingComponentIterFilterFn, @@ -162,9 +153,8 @@ impl Archetype pub fn get_index_for_component(&self, component_id: Uid) -> Option<usize> { assert!( - component_id.kind() == UidKind::Component - || (component_id.kind() == UidKind::Pair - && component_id.target_component() != Uid::wildcard()) + !component_id.is_pair() + || (component_id.is_pair() && component_id.target() != Uid::wildcard()) ); self.component_index_lookup.get(&component_id).copied() @@ -182,17 +172,9 @@ impl Archetype pub fn contains_matching_component(&self, component_id: Uid) -> bool { - let component_id_kind = component_id.kind(); - - debug_assert!( - component_id_kind == UidKind::Component || component_id_kind == UidKind::Pair - ); - - if component_id.kind() == UidKind::Pair - && component_id.target_component() == Uid::wildcard() - { + if component_id.is_pair() && component_id.target() == Uid::wildcard() { return self.component_ids.iter().any(|other_comp_id| { - other_comp_id.kind() == UidKind::Pair + other_comp_id.is_pair() && other_comp_id.has_same_relation_as(component_id) }); } @@ -202,12 +184,9 @@ impl Archetype pub fn contains_component_with_exact_id(&self, component_id: Uid) -> bool { - let component_id_kind = component_id.kind(); - debug_assert!( - component_id_kind == UidKind::Component - || (component_id_kind == UidKind::Pair - && component_id.target_component() != Uid::wildcard()) + !component_id.is_pair() + || (component_id.is_pair() && component_id.target() != Uid::wildcard()) ); self.component_index_lookup.contains_key(&component_id) diff --git a/engine-ecs/src/component/storage/graph.rs b/engine-ecs/src/component/storage/graph.rs index 76200f9..add25e4 100644 --- a/engine-ecs/src/component/storage/graph.rs +++ b/engine-ecs/src/component/storage/graph.rs @@ -3,7 +3,7 @@ use std::vec::IntoIter as VecIntoIter; use hashbrown::{HashMap, HashSet}; use crate::component::storage::archetype::{Archetype, Id as ArchetypeId}; -use crate::uid::{Kind as UidKind, Uid}; +use crate::uid::Uid; use crate::util::{BorrowedOrOwned, StreamingIterator}; #[derive(Debug, Default)] @@ -250,11 +250,6 @@ impl ArchetypeNode insert_fn: impl FnOnce() -> ArchetypeEdges, ) -> &mut ArchetypeEdges { - debug_assert!(matches!( - component_id.kind(), - UidKind::Component | UidKind::Pair - )); - self.edges.entry(component_id).or_insert_with(insert_fn) } |
