diff options
| -rw-r--r-- | engine-ecs/src/component.rs | 3 | ||||
| -rw-r--r-- | engine-ecs/src/lib.rs | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs index 25ec101..aee4904 100644 --- a/engine-ecs/src/component.rs +++ b/engine-ecs/src/component.rs @@ -1,4 +1,4 @@ -use std::any::Any; +use std::any::{Any, TypeId}; use std::fmt::Debug; use std::ops::{Deref, DerefMut}; @@ -371,5 +371,6 @@ impl Default for PartsBuilder pub struct Info { pub type_reflection: &'static crate::reflection::Type, + pub ty_id: TypeId, pub name: &'static str, } diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs index c502b06..88acca9 100644 --- a/engine-ecs/src/lib.rs +++ b/engine-ecs/src/lib.rs @@ -1,6 +1,6 @@ #![deny(clippy::all, clippy::pedantic)] -use std::any::Any; +use std::any::{Any, TypeId}; use std::fmt::Debug; use std::hint::cold_path; use std::rc::Rc; @@ -572,6 +572,7 @@ impl World for component_parts in component_iter { let comp_id = component_parts.id; let comp_name = component_parts.name; + let comp_type_id = (&*component_parts.data).type_id(); if let Err(err) = component_storage.add_entity_component( entity_uid, @@ -590,6 +591,7 @@ impl World comp_id, comp_name, type_reflection, + comp_type_id, component_storage, ); } @@ -608,6 +610,7 @@ impl World comp_id: Uid, comp_name: &'static str, type_reflection: &'static TypeReflection, + type_id: TypeId, component_storage: &mut ComponentStorage, ) { @@ -629,7 +632,12 @@ impl World name: comp_info_name, type_reflection: _, data: comp_info_data, - } = ComponentInfo { type_reflection, name: comp_name }.into_parts(); + } = ComponentInfo { + type_reflection, + name: comp_name, + ty_id: type_id, + } + .into_parts(); if let Err(err) = component_storage .add_entity_component(comp_id, (comp_info_id, comp_info_name, comp_info_data)) |
