From 08e9d6c5023de07e03914892a53fd1a0655ab024 Mon Sep 17 00:00:00 2001 From: Freja Roberts Date: Sun, 3 Nov 2024 23:40:22 +0100 Subject: [PATCH] feat: add add_system --- src/schedule/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/schedule/mod.rs b/src/schedule/mod.rs index aeeba07..b39c331 100644 --- a/src/schedule/mod.rs +++ b/src/schedule/mod.rs @@ -209,6 +209,22 @@ impl Schedule { self } + /// Add a new system to the schedule. + /// Respects order. + pub fn add_system(&mut self, system: impl Into) -> &mut Self { + self.archetype_gen = 0; + let v = match self.systems.first_mut() { + Some(v) => v, + None => { + self.systems.push(Default::default()); + &mut self.systems[0] + } + }; + + v.push(system.into()); + self + } + /// Applies the commands inside of the commandbuffer pub fn flush(self) -> Self { self.with_system(flush_system())