summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-11-29 21:30:53 +0100
committerHampusM <hampus@hampusmat.com>2026-11-29 21:30:53 +0100
commit98d47caa57a9484d39ee4f8d145255d6f5088eac (patch)
treed8d19178fe49ad818c53a550583e9731cbf39f9b
parentc67fe276a9b005a3d158a051208735f2295b6e35 (diff)
feat(engine-ecs): add component type name to component::InfoHEADmaster
-rw-r--r--engine-ecs-macros/src/lib.rs2
-rw-r--r--engine-ecs/src/component.rs14
-rw-r--r--engine-ecs/src/lib.rs3
-rw-r--r--engine-ecs/src/pair.rs5
4 files changed, 24 insertions, 0 deletions
diff --git a/engine-ecs-macros/src/lib.rs b/engine-ecs-macros/src/lib.rs
index 7dee49f..4ae83ce 100644
--- a/engine-ecs-macros/src/lib.rs
+++ b/engine-ecs-macros/src/lib.rs
@@ -136,6 +136,7 @@ pub fn component_derive(input: TokenStream) -> TokenStream
{
#ecs_path::component::Parts::builder()
.name(<Self as Component>::name())
+ .type_name(std::any::type_name::<Self>())
.type_reflection(<Self as Component>::type_reflection())
.build(
<Self as #ecs_path::component::WithAssociatedId>::id(),
@@ -257,6 +258,7 @@ pub fn sole_derive(input: TokenStream) -> TokenStream
{
#ecs_path::component::Parts::builder()
.name(<Self as Sole>::name())
+ .type_name(std::any::type_name::<Self>())
.is_sole(true)
.type_reflection(<Self as Sole>::type_reflection())
.build(
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<dyn Any>,
@@ -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<PairMemberMetadata>,
@@ -327,6 +330,13 @@ impl PartsBuilder
}
#[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
{
self.is_sole = is_sole;
@@ -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: "<unspecified>".into(),
+ type_name: "<unspecified>",
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<Relation, Target> Builder<Relation, Target>
ty: NewRelation::type_reflection(),
ty_id: TypeId::of::<NewRelation>(),
name: NewRelation::name(),
+ type_name: type_name::<NewRelation>(),
is_sole: false,
}),
target_metadata: self.target_metadata,
@@ -75,6 +76,7 @@ impl<Relation, Target> Builder<Relation, Target>
ty: NewTarget::type_reflection(),
ty_id: TypeId::of::<NewTarget>(),
name: NewTarget::name(),
+ type_name: type_name::<NewTarget>(),
is_sole: false,
}),
}
@@ -108,6 +110,7 @@ impl_multiple!(
ty: NewTarget::type_reflection(),
ty_id: TypeId::of::<NewTarget>(),
name: NewTarget::name(),
+ type_name: type_name::<NewTarget>(),
is_sole: false,
}),
}
@@ -131,6 +134,7 @@ impl_multiple!(
ty: NewRelation::type_reflection(),
ty_id: TypeId::of::<NewRelation>(),
name: NewRelation::name(),
+ type_name: type_name::<NewRelation>(),
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,
}