summaryrefslogtreecommitdiff
path: root/ecs/src/component
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/component')
-rw-r--r--ecs/src/component/storage.rs2
-rw-r--r--ecs/src/component/storage/archetype.rs13
2 files changed, 13 insertions, 2 deletions
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<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