From 76774063632fd05f6e62709f69458821cf9307bf Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 2 Dec 2026 15:28:38 +0100 Subject: feat(engine-ecs): add component::Info of_component & of_sole fns --- engine-ecs/src/component.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'engine-ecs') diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs index 71608b1..eb51c03 100644 --- a/engine-ecs/src/component.rs +++ b/engine-ecs/src/component.rs @@ -1,4 +1,4 @@ -use std::any::Any; +use std::any::{type_name, Any}; use std::borrow::Cow; use std::fmt::Debug; use std::ops::{Deref, DerefMut}; @@ -17,6 +17,7 @@ use crate::lock::{ }; use crate::pair::{MemberMetadata as PairMemberMetadata, Pair}; use crate::reflection::Type as TypeReflection; +use crate::sole::Sole; use crate::system::Input as SystemInput; use crate::uid::Uid; use crate::{EntityComponentRef, World}; @@ -379,6 +380,24 @@ impl Default for Info impl Info { + pub fn of_component() -> Self + { + Self::default() + .with_name(ComponentT::name()) + .with_type_name(type_name::()) + .with_is_sole(false) + .with_type_reflection(ComponentT::type_reflection()) + } + + pub fn of_sole() -> Self + { + Self::default() + .with_name(SoleT::name()) + .with_type_name(type_name::()) + .with_is_sole(true) + .with_type_reflection(SoleT::type_reflection()) + } + #[must_use] pub fn with_name(mut self, name: impl Into>) -> Self { -- cgit v1.2.3-18-g5258