From 7d578700747928fca0f0f1a4fae2c0cde0fe74f6 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 3 Aug 2026 14:28:41 +0200 Subject: feat(engine-ecs): create component info ents for components from pairs --- engine-ecs/src/component.rs | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'engine-ecs/src/component.rs') diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs index 30869b5..9220ffb 100644 --- a/engine-ecs/src/component.rs +++ b/engine-ecs/src/component.rs @@ -14,7 +14,8 @@ use crate::lock::{ ReadGuard, WriteGuard, }; -use crate::pair::Pair; +use crate::pair::{MemberMetadata as PairMemberMetadata, Pair}; +use crate::reflection::Type as TypeReflection; use crate::system::Input as SystemInput; use crate::uid::Uid; use crate::util::Array; @@ -31,7 +32,7 @@ pub trait Component: SystemInput + Any + IntoParts where Self: Sized; - fn type_reflection() -> Option<&'static crate::reflection::Type> + fn type_reflection() -> Option<&'static TypeReflection> where Self: Sized; @@ -293,8 +294,10 @@ pub struct Parts { pub id: Uid, pub name: &'static str, - pub type_reflection: Option<&'static crate::reflection::Type>, + pub type_reflection: Option<&'static TypeReflection>, pub data: Box, + pub pair_relation_metadata: Option, + pub pair_target_metadata: Option, } impl Parts @@ -310,7 +313,9 @@ impl Parts pub struct PartsBuilder { name: &'static str, - type_reflection: Option<&'static crate::reflection::Type>, + type_reflection: Option<&'static TypeReflection>, + pair_relation_metadata: Option, + pair_target_metadata: Option, } impl PartsBuilder @@ -325,13 +330,33 @@ impl PartsBuilder #[must_use] pub fn type_reflection( mut self, - type_reflection: Option<&'static crate::reflection::Type>, + type_reflection: Option<&'static TypeReflection>, ) -> Self { self.type_reflection = type_reflection; self } + #[must_use] + pub fn pair_relation_metadata( + mut self, + metadata: Option, + ) -> Self + { + self.pair_relation_metadata = metadata; + self + } + + #[must_use] + pub fn pair_target_metadata( + mut self, + metadata: Option, + ) -> Self + { + self.pair_target_metadata = metadata; + self + } + #[must_use] pub fn build(self, id: Uid, data: Data) -> Parts { @@ -340,6 +365,8 @@ impl PartsBuilder name: self.name, type_reflection: self.type_reflection, data: Box::new(data), + pair_relation_metadata: self.pair_relation_metadata, + pair_target_metadata: self.pair_target_metadata, } } @@ -351,6 +378,8 @@ impl PartsBuilder name: self.name, type_reflection: self.type_reflection, data, + pair_relation_metadata: self.pair_relation_metadata, + pair_target_metadata: self.pair_target_metadata, } } } @@ -362,6 +391,8 @@ impl Default for PartsBuilder Self { name: "(unspecified)", type_reflection: None, + pair_relation_metadata: None, + pair_target_metadata: None, } } } @@ -370,7 +401,7 @@ impl Default for PartsBuilder #[non_exhaustive] pub struct Info { - pub type_reflection: Option<&'static crate::reflection::Type>, + pub type_reflection: Option<&'static TypeReflection>, pub ty_id: TypeId, pub name: &'static str, } -- cgit v1.2.3-18-g5258