Skip to content

Commit

Permalink
feat: add add_system
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Nov 3, 2024
1 parent 339d5ae commit 08e9d6c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BoxedSystem>) -> &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())
Expand Down

0 comments on commit 08e9d6c

Please sign in to comment.