From 7d25c21cdf4b46cdab680f11110fb23676c6141b Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 10 Apr 2025 17:39:21 +0200 Subject: feat(ecs): re-add support for component events --- ecs/src/component/storage/archetype.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ecs/src/component/storage') diff --git a/ecs/src/component/storage/archetype.rs b/ecs/src/component/storage/archetype.rs index 10a665e..f8c204b 100644 --- a/ecs/src/component/storage/archetype.rs +++ b/ecs/src/component/storage/archetype.rs @@ -314,18 +314,29 @@ impl Entity #[derive(Debug)] pub struct EntityComponent { + id: Uid, component: Lock>, } impl EntityComponent { - pub fn new(component: Box, component_name: &'static str) -> Self + pub fn new( + component: Box, + component_id: Uid, + component_name: &'static str, + ) -> Self { Self { + id: component_id, component: Lock::new(component, component_name), } } + pub fn id(&self) -> Uid + { + self.id + } + pub fn component(&self) -> &Lock> { &self.component -- cgit v1.2.3-18-g5258