diff options
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 504a106..ad83d1e 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -452,13 +452,13 @@ impl World fn add_entity_components( entity_uid: Uid, - components: impl IntoIterator<Item = Box<dyn Component>>, + components: impl IntoIterator<Item = (Uid, Box<dyn Component>)>, component_storage: &mut ComponentStorage, ) { - for component in components { - if let Err(err) = - component_storage.add_entity_component(entity_uid, component) + for (component_id, component) in components { + if let Err(err) = component_storage + .add_entity_component(entity_uid, (component_id, component)) { tracing::error!("Failed to add component to entity: {err}"); } @@ -553,12 +553,12 @@ pub struct EntityComponent pub component: Lock<Box<dyn Component>>, } -impl From<Box<dyn Component>> for EntityComponent +impl EntityComponent { - fn from(component: Box<dyn Component>) -> Self + pub fn new(id: Uid, component: Box<dyn Component>) -> Self { Self { - id: component.self_id(), + id, name: component.type_name(), component: Lock::new(component), } |