summaryrefslogtreecommitdiff
path: root/engine-ecs/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-08 00:43:40 +0200
committerHampusM <hampus@hampusmat.com>2026-07-08 00:43:40 +0200
commit378841f5918b28052d938308c52f4591d1ebbf86 (patch)
tree92c43099f7b0dd6e22b8994be22ecc1809678705 /engine-ecs/src/lib.rs
parent548cfe53130537dfee33d143e8a563879e30e1a2 (diff)
feat(engine-ecs): add type ID to component::Info struct
Diffstat (limited to 'engine-ecs/src/lib.rs')
-rw-r--r--engine-ecs/src/lib.rs12
1 files changed, 10 insertions, 2 deletions
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))