From b35d5288c3169de38fd13a0c3000c251cd8f8195 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 2 Dec 2026 16:55:17 +0100 Subject: feat(engine-ecs): add module path to component::Info --- engine-ecs/src/component.rs | 16 +++++++++++++++- engine-ecs/src/sole.rs | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'engine-ecs') diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs index ce19c09..5e70af8 100644 --- a/engine-ecs/src/component.rs +++ b/engine-ecs/src/component.rs @@ -35,6 +35,9 @@ pub trait Component: WithAssociatedId + SystemInput + Any + Into /// Returns the name of this component. fn name() -> Cow<'static, str>; + + /// Returns the module path of this component. + fn module_path() -> &'static str; } pub trait WithAssociatedId @@ -361,6 +364,7 @@ pub struct Info pub type_reflection: Option<&'static TypeReflection>, pub name: Cow<'static, str>, pub type_name: &'static str, + pub module_path: &'static str, pub is_sole: bool, } @@ -372,6 +376,7 @@ impl Default for Info type_reflection: None, name: "".into(), type_name: "", + module_path: "", is_sole: false, } } @@ -384,6 +389,7 @@ impl Info Self::default() .with_name(ComponentT::name()) .with_type_name(type_name::()) + .with_module_path(ComponentT::module_path()) .with_is_sole(false) .with_type_reflection(ComponentT::type_reflection()) } @@ -393,6 +399,7 @@ impl Info Self::default() .with_name(SoleT::name()) .with_type_name(type_name::()) + .with_module_path(SoleT::module_path()) .with_is_sole(true) .with_type_reflection(SoleT::type_reflection()) } @@ -407,7 +414,14 @@ impl Info #[must_use] pub fn with_type_name(mut self, type_name: &'static str) -> Self { - self.type_name = type_name.into(); + self.type_name = type_name; + self + } + + #[must_use] + pub fn with_module_path(mut self, module_path: &'static str) -> Self + { + self.module_path = module_path; self } diff --git a/engine-ecs/src/sole.rs b/engine-ecs/src/sole.rs index 568be3e..1430cc2 100644 --- a/engine-ecs/src/sole.rs +++ b/engine-ecs/src/sole.rs @@ -19,6 +19,9 @@ pub trait Sole: Any + ComponentWithAssociatedId + Into /// Returns the name of this component. fn name() -> Cow<'static, str>; + + /// Returns the module path of this component. + fn module_path() -> &'static str; } /// Marker component for the entities of soles. -- cgit v1.2.3-18-g5258