diff options
| author | HampusM <hampus@hampusmat.com> | 2026-05-02 17:30:03 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-05-02 17:30:03 +0200 |
| commit | e698922e86c217a261db114ce0392060503f0013 (patch) | |
| tree | 9c879601a1fccf5d6126d62fd4e05fd3965cad93 /ecs/src/component/storage.rs | |
| parent | aa02cdecfbfc2b2513e37ef72c720477d30a310c (diff) | |
feat(ecs): allow creation of already existing entities
Diffstat (limited to 'ecs/src/component/storage.rs')
| -rw-r--r-- | ecs/src/component/storage.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs index d974967..dc38b6a 100644 --- a/ecs/src/component/storage.rs +++ b/ecs/src/component/storage.rs @@ -145,12 +145,12 @@ impl Storage Some(self.graph.get_node_by_id(id)?.archetype()) } - pub fn create_entity(&mut self, uid: Uid) -> Result<(), Error> + pub fn create_entity(&mut self, uid: Uid) -> Result<(), EntityAlreadyExistsError> { debug_assert_eq!(uid.kind(), UidKind::Entity); if self.entity_archetype_lookup.contains_key(&uid) { - return Err(Error::EntityAlreadyExists(uid)); + return Err(EntityAlreadyExistsError); } let empty_archetype_id = ArchetypeId::new_empty(); @@ -736,9 +736,6 @@ impl ArchetypeRefIter<'_, '_> #[derive(Debug, thiserror::Error)] pub enum Error { - #[error("Entity with ID {0:?} already exists")] - EntityAlreadyExists(Uid), - #[error("Entity with ID {0:?} does not exist")] EntityDoesNotExist(Uid), @@ -755,6 +752,10 @@ pub enum Error }, } +#[derive(Debug, thiserror::Error)] +#[error("Entity with already exists")] +pub struct EntityAlreadyExistsError; + #[derive(Debug)] struct ImaginaryArchetype { |
