From 98d47caa57a9484d39ee4f8d145255d6f5088eac Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 29 Nov 2026 21:30:53 +0100 Subject: feat(engine-ecs): add component type name to component::Info --- engine-ecs/src/component.rs | 14 ++++++++++++++ engine-ecs/src/lib.rs | 3 +++ engine-ecs/src/pair.rs | 5 +++++ 3 files changed, 22 insertions(+) (limited to 'engine-ecs/src') diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs index 3e93930..f27718d 100644 --- a/engine-ecs/src/component.rs +++ b/engine-ecs/src/component.rs @@ -264,6 +264,7 @@ pub struct Parts { pub id: Uid, pub name: Cow<'static, str>, + pub type_name: &'static str, pub is_sole: bool, pub type_reflection: Option<&'static TypeReflection>, pub data: Box, @@ -288,6 +289,7 @@ impl Parts Self::builder() .type_reflection(component_info.type_reflection) .name(component_info.name.clone()) + .type_name(component_info.type_name) .is_sole(component_info.is_sole) .build_with_any_data(id, data) } @@ -311,6 +313,7 @@ impl IntoParts for Parts pub struct PartsBuilder { name: Cow<'static, str>, + type_name: &'static str, is_sole: bool, type_reflection: Option<&'static TypeReflection>, pair_relation_metadata: Option, @@ -326,6 +329,13 @@ impl PartsBuilder self } + #[must_use] + pub fn type_name(mut self, type_name: &'static str) -> Self + { + self.type_name = type_name.into(); + self + } + #[must_use] pub fn is_sole(mut self, is_sole: bool) -> Self { @@ -364,6 +374,7 @@ impl PartsBuilder Parts { id, name: self.name, + type_name: self.type_name, is_sole: self.is_sole, type_reflection: self.type_reflection, data: Box::new(data), @@ -378,6 +389,7 @@ impl PartsBuilder Parts { id, name: self.name, + type_name: self.type_name, is_sole: self.is_sole, type_reflection: self.type_reflection, data, @@ -393,6 +405,7 @@ impl Default for PartsBuilder { Self { name: "".into(), + type_name: "", is_sole: false, type_reflection: None, pair_relation_metadata: None, @@ -408,6 +421,7 @@ pub struct Info pub type_reflection: Option<&'static TypeReflection>, pub ty_id: TypeId, pub name: Cow<'static, str>, + pub type_name: &'static str, pub is_sole: bool, } diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs index 397605c..80af3d4 100644 --- a/engine-ecs/src/lib.rs +++ b/engine-ecs/src/lib.rs @@ -702,6 +702,7 @@ impl World type_reflection: pair_relation_metadata.ty, ty_id: pair_relation_metadata.ty_id, name: pair_relation_metadata.name, + type_name: pair_relation_metadata.type_name, is_sole: pair_relation_metadata.is_sole, }, ); @@ -715,6 +716,7 @@ impl World type_reflection: pair_target_metadata.ty, ty_id: pair_target_metadata.ty_id, name: pair_target_metadata.name, + type_name: pair_target_metadata.type_name, is_sole: pair_target_metadata.is_sole, }, ); @@ -730,6 +732,7 @@ impl World type_reflection: component_parts.type_reflection, ty_id: comp_type_id, name: comp_name, + type_name: component_parts.type_name, is_sole: component_parts.is_sole, }, ); diff --git a/engine-ecs/src/pair.rs b/engine-ecs/src/pair.rs index 296e9cc..a6066e1 100644 --- a/engine-ecs/src/pair.rs +++ b/engine-ecs/src/pair.rs @@ -49,6 +49,7 @@ impl Builder ty: NewRelation::type_reflection(), ty_id: TypeId::of::(), name: NewRelation::name(), + type_name: type_name::(), is_sole: false, }), target_metadata: self.target_metadata, @@ -75,6 +76,7 @@ impl Builder ty: NewTarget::type_reflection(), ty_id: TypeId::of::(), name: NewTarget::name(), + type_name: type_name::(), is_sole: false, }), } @@ -108,6 +110,7 @@ impl_multiple!( ty: NewTarget::type_reflection(), ty_id: TypeId::of::(), name: NewTarget::name(), + type_name: type_name::(), is_sole: false, }), } @@ -131,6 +134,7 @@ impl_multiple!( ty: NewRelation::type_reflection(), ty_id: TypeId::of::(), name: NewRelation::name(), + type_name: type_name::(), is_sole: false, }), target_metadata: self.target_metadata, @@ -786,6 +790,7 @@ pub struct MemberMetadata pub ty: Option<&'static TypeReflection>, pub ty_id: TypeId, pub name: Cow<'static, str>, + pub type_name: &'static str, pub is_sole: bool, } -- cgit v1.2.3-18-g5258