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.rs | 2 +- ecs/src/component/storage/archetype.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'ecs/src/component') diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs index 9cf4433..14f3ea4 100644 --- a/ecs/src/component/storage.rs +++ b/ecs/src/component/storage.rs @@ -268,7 +268,7 @@ impl Storage entity.insert_component( component_id, - ArchetypeEntityComponent::new(component, component_name), + ArchetypeEntityComponent::new(component, component_id, component_name), add_edge_archetype, ); 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