summaryrefslogtreecommitdiff
path: root/ecs/src/extension.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-05-21 17:55:20 +0200
committerHampusM <hampus@hampusmat.com>2026-05-21 17:55:20 +0200
commit8022e8998290b067b8aa0cb9cba8ba410826bdab (patch)
tree7171e79ce530e03079046ee8fd12167160c45480 /ecs/src/extension.rs
parent412cee02c252f91bcf0b70a3f5cc5fca6d2b4c62 (diff)
chore: rename ecs* crates to engine-ecs*
Diffstat (limited to 'ecs/src/extension.rs')
-rw-r--r--ecs/src/extension.rs72
1 files changed, 0 insertions, 72 deletions
diff --git a/ecs/src/extension.rs b/ecs/src/extension.rs
deleted file mode 100644
index 9c6614b..0000000
--- a/ecs/src/extension.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-use crate::component::Sequence as ComponentSequence;
-use crate::entity::Declaration as EntityDeclaration;
-use crate::sole::Sole;
-use crate::system::observer::Observer;
-use crate::system::System;
-use crate::uid::Uid;
-use crate::{SoleAlreadyExistsError, World};
-
-/// A collection of systems, entities & soles that can be added to a [`World`].
-pub trait Extension
-{
- fn collect(self, collector: Collector<'_>);
-}
-
-/// Passed to a [`Extension`] to collects it's systems, entities & soles.
-pub struct Collector<'world>
-{
- world: &'world mut World,
-}
-
-impl<'world> Collector<'world>
-{
- /// Returns a new `Collector` for the given [`World`].
- pub fn new(world: &'world mut World) -> Self
- {
- Self { world }
- }
-
- /// Adds a system to the [`World`].
- pub fn add_system<'this, SystemImpl>(
- &'this mut self,
- phase_euid: Uid,
- system: impl System<'this, SystemImpl>,
- )
- {
- self.world.register_system(phase_euid, system);
- }
-
- /// Adds a observer system to the [`World`].
- pub fn add_observer<'this, SystemImpl>(
- &'this mut self,
- observer: impl Observer<'this, SystemImpl>,
- )
- {
- self.world.register_observer(observer);
- }
-
- /// Adds a entity to the [`World`].
- pub fn add_entity<Comps>(&mut self, components: Comps)
- where
- Comps: ComponentSequence,
- {
- self.world.create_entity(components);
- }
-
- /// Adds a declared entity to the [`World`].
- pub fn add_declared_entity(&mut self, entity_decl: &EntityDeclaration)
- {
- self.world.create_declared_entity(entity_decl);
- }
-
- /// Adds a globally shared singleton value to the [`World`].
- ///
- /// # Errors
- /// Returns `Err` if this [`Sole`] has already been added.
- pub fn add_sole<SoleT>(&mut self, sole: SoleT) -> Result<(), SoleAlreadyExistsError>
- where
- SoleT: Sole,
- {
- self.world.add_sole(sole)
- }
-}