summaryrefslogtreecommitdiff
path: root/ecs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs')
-rw-r--r--ecs/src/lib.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 11e67f7..df25f46 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -40,6 +40,7 @@ struct Entity
#[derive(Debug)]
struct EntityComponent
{
+ id: TypeId,
component: Lock<Box<dyn Component>>,
}
@@ -71,7 +72,10 @@ impl World
components: components
.into_vec()
.into_iter()
- .map(|component| EntityComponent { component: Lock::new(component) })
+ .map(|component| EntityComponent {
+ id: (*component).type_id(),
+ component: Lock::new(component),
+ })
.collect(),
});
}
@@ -140,6 +144,7 @@ impl World
components: components
.into_iter()
.map(|component| EntityComponent {
+ id: (*component).type_id(),
component: Lock::new(component),
})
.collect(),
@@ -339,9 +344,7 @@ fn find_entity_with_components<'world>(
let entity_components = entity
.components
.iter()
- .filter_map(|component| {
- Some(component.component.read_nonblock().ok()?.as_ref().type_id())
- })
+ .map(|component| component.id)
.collect::<HashSet<_>>();
if component_type_ids