Skip to content

Commit

Permalink
feat(bones_ecs): make insert_stage_before/after() chainable. (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Feb 9, 2023
1 parent b912295 commit 7c578b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/bones_ecs/src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ impl SystemStages {
&mut self,
label: L,
stage: S,
) {
) -> &mut Self {
let stage_idx = self
.stages
.iter()
.position(|x| x.id() == label.id())
.unwrap_or_else(|| panic!("Could not find stage with label `{}`", label.name()));
self.stages.insert(stage_idx, Box::new(stage));

self
}

/// Insert a new stage, after another existing stage
Expand All @@ -91,13 +93,15 @@ impl SystemStages {
&mut self,
label: L,
stage: S,
) {
) -> &mut Self {
let stage_idx = self
.stages
.iter()
.position(|x| x.id() == label.id())
.unwrap_or_else(|| panic!("Could not find stage with label `{}`", label.name()));
self.stages.insert(stage_idx + 1, Box::new(stage));

self
}
}

Expand Down

0 comments on commit 7c578b4

Please sign in to comment.