Skip to content

Commit aa990b8

Browse files
committed
add method for systems
1 parent 0bf6210 commit aa990b8

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "magma_ecs"
3-
version = "0.2.0-alpha.1"
3+
version = "0.2.0-alpha.2"
44
edition = "2021"
55
license = "MIT"
66
description = "Entity-Component-System for the Magma3D game engine"

src/systems.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ impl Systems {
4141
self
4242
}
4343

44+
/// Add a system
45+
pub fn add(
46+
&mut self,
47+
run: fn(&World),
48+
name: &'static str,
49+
deps: &'static [&'static str],
50+
) -> &mut Self {
51+
self.0.push(System::new(run, name, deps));
52+
self
53+
}
54+
4455
/// Build a [`Dispatcher`] from the [`Systems`] to be run on the [`World`].
4556
pub fn build_dispatcher(self) -> Dispatcher {
4657
Dispatcher::from_systems(self)
@@ -63,6 +74,14 @@ mod tests {
6374
assert_eq!(systems.0[1].name, "system_2");
6475
}
6576

77+
#[test]
78+
fn add_systems() {
79+
let mut systems = Systems::new();
80+
systems
81+
.add(system_1, "system_1", &[])
82+
.add(system_2, "system_2", &["system_1"]);
83+
}
84+
6685
#[test]
6786
fn build_dispatcher() {
6887
let systems = Systems::new().with(system_1, "system_1", &[]).with(

0 commit comments

Comments
 (0)