diff options
author | HampusM <hampus@hampusmat.com> | 2025-04-10 17:39:21 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-04-10 17:39:38 +0200 |
commit | 7d25c21cdf4b46cdab680f11110fb23676c6141b (patch) | |
tree | cc953dbbb5cc4f2da36b9b5ad7c569ee0aa5fcd7 /ecs/src/component/storage | |
parent | 3ba82dd26869dad69f686d38bb70caefeaa25bfc (diff) |
feat(ecs): re-add support for component events
Diffstat (limited to 'ecs/src/component/storage')
-rw-r--r-- | ecs/src/component/storage/archetype.rs | 13 |
1 files changed, 12 insertions, 1 deletions
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<Box<dyn Any>>, } impl EntityComponent { - pub fn new(component: Box<dyn Any>, component_name: &'static str) -> Self + pub fn new( + component: Box<dyn Any>, + 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<Box<dyn Any>> { &self.component |