Skip to content

Commit e51588e

Browse files
committed
#113 - Reminder to run systems.
1 parent 533f6ab commit e51588e

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

book/src/chapter_7.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl<'a> System<'a> for MapIndexingSystem {
411411
if let Some(_p) = _p {
412412
map.blocked[idx] = true;
413413
}
414-
414+
415415
// Push the entity to the appropriate index slot. It's a Copy
416416
// type, so we don't need to clone it (we want to avoid moving it out of the ECS!)
417417
map.tile_content[idx].push(entity);
@@ -728,7 +728,7 @@ fn tick(&mut self, ctx : &mut Rltk) {
728728
let runstate = self.ecs.fetch::<RunState>();
729729
newrunstate = *runstate;
730730
}
731-
731+
732732
match newrunstate {
733733
RunState::PreRun => {
734734
self.run_systems();
@@ -792,6 +792,26 @@ impl<'a> System<'a> for MonsterAI {
792792
if *runstate != RunState::MonsterTurn { return; }
793793
```
794794

795+
Don't forget to make sure that all of the systems are now in `run_systems` (in `main.rs`):
796+
797+
```rust
798+
impl State {
799+
fn run_systems(&mut self) {
800+
let mut vis = VisibilitySystem{};
801+
vis.run_now(&self.ecs);
802+
let mut mob = MonsterAI{};
803+
mob.run_now(&self.ecs);
804+
let mut mapindex = MapIndexingSystem{};
805+
mapindex.run_now(&self.ecs);
806+
let mut melee = MeleeCombatSystem{};
807+
melee.run_now(&self.ecs);
808+
let mut damage = DamageSystem{};
809+
damage.run_now(&self.ecs);
810+
self.ecs.maintain();
811+
}
812+
}
813+
```
814+
795815
If you `cargo run` the project, it now behaves as you'd expect: the player moves, and things he/she kills die before they can respond.
796816

797817
# Wrapping Up

book/src/contributors.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following people have contributed to this project:
4747
* [HammerAndTongs](https://github.com/hammerandtongs) noticed that the A* implementation also needs to implement `get_pathing_distance`.
4848
* [mdtro](https://github.com/mdtro) found a problem with the Chapter 7 code.
4949
* [pprobst](https://github.com/pprobst) noticed that tool-tips were revealing hidden monsters.
50+
* [Ben Doerr](https://github.com/bendoerr) reminded me to remind you to run the new systems created in chapter 7.
5051

5152
## Supporters
5253

0 commit comments

Comments
 (0)