From ef7b76ff39d501028852835649f618fcbe17a003 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 13 Apr 2024 17:38:45 +0200 Subject: feat(ecs): add extensions --- ecs/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ecs/src/lib.rs') diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 285f3b3..009ff21 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -12,6 +12,7 @@ use std::vec::Drain; use crate::actions::Action; use crate::component::{Component, Sequence as ComponentSequence}; use crate::event::{Event, Id as EventId, Ids, Sequence as EventSequence}; +use crate::extension::{Collector as ExtensionCollector, Extension}; use crate::lock::Lock; use crate::sole::Sole; use crate::system::{System, TypeErased as TypeErasedSystem}; @@ -20,6 +21,7 @@ use crate::type_name::TypeName; pub mod actions; pub mod component; pub mod event; +pub mod extension; pub mod lock; pub mod query; pub mod sole; @@ -120,6 +122,17 @@ impl World drop(event); } + /// Adds a extensions. + /// + /// # Panics + /// Will panic if mutable internal lock cannot be acquired. + pub fn add_extension(&mut self, extension: impl Extension) + { + let extension_collector = ExtensionCollector::new(self); + + extension.collect(extension_collector); + } + /// Emits a event, running all systems listening to the event for each compatible /// entity. /// -- cgit v1.2.3-18-g5258