summaryrefslogtreecommitdiff
path: root/ecs/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r--ecs/src/lib.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 009ff21..c2fc9c7 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -10,7 +10,11 @@ use std::sync::Arc;
use std::vec::Drain;
use crate::actions::Action;
-use crate::component::{Component, Sequence as ComponentSequence};
+use crate::component::{
+ Component,
+ IsOptional as ComponentIsOptional,
+ Sequence as ComponentSequence,
+};
use crate::event::{Event, Id as EventId, Ids, Sequence as EventSequence};
use crate::extension::{Collector as ExtensionCollector, Extension};
use crate::lock::Lock;
@@ -281,7 +285,7 @@ impl ComponentStorage
fn find_entity_with_components(
&self,
start_index: usize,
- component_type_ids: &[TypeId],
+ component_type_ids: &[(TypeId, ComponentIsOptional)],
) -> Option<(usize, &Entity)>
{
// TODO: This is a really dumb and slow way to do this. Refactor the world
@@ -294,9 +298,13 @@ impl ComponentStorage
.map(|component| component.id)
.collect::<HashSet<_>>();
- if component_type_ids.iter().all(|component_type_id| {
- entity_components.contains(component_type_id)
- }) {
+ if component_type_ids
+ .iter()
+ .filter(|(_, is_optional)| *is_optional == ComponentIsOptional::No)
+ .all(|(component_type_id, _)| {
+ entity_components.contains(component_type_id)
+ })
+ {
return true;
}