summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-12-02 16:55:17 +0100
committerHampusM <hampus@hampusmat.com>2026-12-02 16:55:17 +0100
commitb35d5288c3169de38fd13a0c3000c251cd8f8195 (patch)
tree1805ce04d1d5c57a0a40719f31e62b206acf6189
parentacb55235c1baed08a106bce3abc5b95b5a12e7aa (diff)
feat(engine-ecs): add module path to component::InfoHEADmaster
-rw-r--r--engine-ecs-macros/src/lib.rs10
-rw-r--r--engine-ecs/src/component.rs16
-rw-r--r--engine-ecs/src/sole.rs3
3 files changed, 28 insertions, 1 deletions
diff --git a/engine-ecs-macros/src/lib.rs b/engine-ecs-macros/src/lib.rs
index 3a025fb..28b0ee5 100644
--- a/engine-ecs-macros/src/lib.rs
+++ b/engine-ecs-macros/src/lib.rs
@@ -124,6 +124,11 @@ pub fn component_derive(input: TokenStream) -> TokenStream
{
stringify!(#item_ident).into()
}
+
+ fn module_path() -> &'static str
+ {
+ module_path!().rsplit_once("::").unwrap().0
+ }
}
impl SystemInput for #item_ident
@@ -250,6 +255,11 @@ pub fn sole_derive(input: TokenStream) -> TokenStream
{
stringify!(#item_ident).into()
}
+
+ fn module_path() -> &'static str
+ {
+ module_path!().rsplit_once("::").unwrap().0
+ }
}
impl From<#item_ident> for #ecs_path::component::Parts
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<Parts>
/// 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: "<unspecified>".into(),
type_name: "<unspecified>",
+ module_path: "<unspecified>",
is_sole: false,
}
}
@@ -384,6 +389,7 @@ impl Info
Self::default()
.with_name(ComponentT::name())
.with_type_name(type_name::<ComponentT>())
+ .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::<SoleT>())
+ .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<ComponentParts>
/// 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.