summaryrefslogtreecommitdiff
path: root/engine-ecs/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-30 06:50:48 +0200
committerHampusM <hampus@hampusmat.com>2026-08-30 06:50:48 +0200
commitaab9155405ebead3eff92ffcfb262c825b29d106 (patch)
treebd1009712910f0b859f8cfed5ee71a51f5b5dc70 /engine-ecs/src
parent80d2cee1b457fc25c32fa780fb349c97889e0df1 (diff)
fix(engine-ecs): make World::add_sole actually check if sole already existsHEADmaster
Diffstat (limited to 'engine-ecs/src')
-rw-r--r--engine-ecs/src/lib.rs13
1 files 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;