diff options
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 40b2021..452f657 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -23,6 +23,7 @@ use crate::extension::{Collector as ExtensionCollector, Extension}; use crate::lock::{Lock, WriteGuard}; use crate::query::options::Options as QueryOptions; use crate::sole::Sole; +use crate::stats::Stats; use crate::system::{System, TypeErased as TypeErasedSystem}; use crate::tuple::Reduce as TupleReduce; use crate::type_name::TypeName; @@ -36,6 +37,7 @@ pub mod lock; pub mod query; pub mod relationship; pub mod sole; +pub mod stats; pub mod system; pub mod tuple; pub mod type_name; @@ -60,7 +62,13 @@ impl World #[must_use] pub fn new() -> Self { - Self::default() + let mut world = Self::default(); + + world + .add_sole(Stats::default()) + .expect("World already has stats sole"); + + world } /// Creates a new entity with the given components. @@ -267,6 +275,20 @@ impl World if self.stop.load(Ordering::Relaxed) { break; } + + let mut stats_lock = self + .data + .sole_storage + .get::<Stats>() + .expect("No stats sole found") + .write_nonblock() + .expect("Failed to aquire read-write stats sole lock"); + + let stats = stats_lock + .downcast_mut::<Stats>() + .expect("Casting stats sole to Stats type failed"); + + stats.current_tick += 1; } } |