summaryrefslogtreecommitdiff
path: root/ecs/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index 604f54d..9310995 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -3,9 +3,10 @@ use std::fmt::Debug;
use seq_macro::seq;
-use crate::lock::{Lock, WriteGuard};
+use crate::lock::WriteGuard;
use crate::system::{ComponentRefMut, Input as SystemInput};
use crate::type_name::TypeName;
+use crate::EntityComponent;
pub mod local;
@@ -112,7 +113,7 @@ pub trait Sequence
fn type_ids() -> Vec<(TypeId, IsOptional)>;
fn from_components<'component>(
- components: impl Iterator<Item = &'component Lock<Box<dyn Component>>>,
+ components: impl Iterator<Item = &'component EntityComponent>,
) -> Self::Refs<'component>;
}
@@ -180,7 +181,7 @@ macro_rules! inner {
}
fn from_components<'component>(
- components: impl Iterator<Item = &'component Lock<Box<dyn Component>>>,
+ components: impl Iterator<Item = &'component EntityComponent>,
) -> Self::Refs<'component>
{
#(
@@ -188,12 +189,14 @@ macro_rules! inner {
)*
for comp in components {
- let comp_ref = comp
- .write_nonblock()
- .expect("Failed to acquire read-write component lock");
-
#(
- if comp_ref.is::<Comp~I::Component>() {
+ if comp.id == TypeId::of::<Comp~I::Component>() {
+ let comp_ref = comp.component
+ .write_nonblock()
+ .expect(
+ "Failed to acquire read-write component lock"
+ );
+
comp_~I = Some(comp_ref);
continue;
}