From aab9155405ebead3eff92ffcfb262c825b29d106 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 30 Aug 2026 06:50:48 +0200 Subject: fix(engine-ecs): make World::add_sole actually check if sole already exists --- engine-ecs/src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs index b987f65..0d7df79 100644 --- a/engine-ecs/src/lib.rs +++ b/engine-ecs/src/lib.rs @@ -225,6 +225,15 @@ impl World where SoleT: Sole, { + if self + .data + .component_storage + .get_entity_archetype(SoleT::id()) + .is_some() + { + return Err(SoleAlreadyExistsError); + } + let name = sole.name(); self.create_ent( @@ -962,5 +971,5 @@ impl ActionQueue } #[derive(Debug, thiserror::Error)] -#[error("Sole {0} already exists")] -pub struct SoleAlreadyExistsError(pub &'static str); +#[error("Sole already exists")] +pub struct SoleAlreadyExistsError; -- cgit v1.2.3-18-g5258