diff options
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 |