From 3c117bcd9455ffbcec5cd59dab37db0786e15e02 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 29 Nov 2026 21:16:11 +0100 Subject: feat(engine-ecs): change meaning of component name to type identifier --- engine-ecs/src/component/storage.rs | 8 +++----- engine-ecs/src/component/storage/archetype.rs | 13 ++----------- 2 files changed, 5 insertions(+), 16 deletions(-) (limited to 'engine-ecs/src/component') diff --git a/engine-ecs/src/component/storage.rs b/engine-ecs/src/component/storage.rs index 98f8d46..7a49110 100644 --- a/engine-ecs/src/component/storage.rs +++ b/engine-ecs/src/component/storage.rs @@ -261,7 +261,7 @@ impl Storage pub fn add_entity_component( &mut self, entity_uid: Uid, - (component_id, component_name, component): (Uid, &'static str, Box), + (component_id, component): (Uid, Box), ) -> Result<(), Error> { let Some(archetype_id) = self.entity_archetype_lookup.get(&entity_uid) else { @@ -334,7 +334,7 @@ impl Storage entity.insert_component( component_id, - ArchetypeEntityComponent::new(component, component_name), + ArchetypeEntityComponent::new(component), add_edge_archetype, ); @@ -403,8 +403,7 @@ impl Storage .remove_entity(entity_uid) .expect("Entity should exist in archetype"); - let removed_component = - entity.remove_component(component_id, archetype_node.archetype()); + entity.remove_component(component_id, archetype_node.archetype()); self.graph .get_node_by_id_mut(remove_edge_id) @@ -418,7 +417,6 @@ impl Storage tracing::debug!( entity_id = %entity_uid, component_id = %component_id, - component_name = removed_component.name(), "Removed component from entity" ); diff --git a/engine-ecs/src/component/storage/archetype.rs b/engine-ecs/src/component/storage/archetype.rs index 480a1da..64ab587 100644 --- a/engine-ecs/src/component/storage/archetype.rs +++ b/engine-ecs/src/component/storage/archetype.rs @@ -328,28 +328,19 @@ impl Entity pub struct EntityComponent { component: Lock>, - name: &'static str, } impl EntityComponent { - pub fn new(component: Box, component_name: &'static str) -> Self + pub fn new(component: Box) -> Self { - Self { - component: Lock::new(component, component_name), - name: component_name, - } + Self { component: Lock::new(component) } } pub fn component(&self) -> &Lock> { &self.component } - - pub fn name(&self) -> &str - { - self.name - } } /// Archetype ID. -- cgit v1.2.3-18-g5258