From 42549b250b9909ef08e5b0913ce3fa701000acd5 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Sun, 29 Aug 2021 20:38:49 -0700 Subject: [PATCH] The first update of MonsterAI can't take RunState as it's not embedded yet. At this stage of the code RunState is still embedded in State and not an entity in the world so it can't be passed over in data. A few sections down when RunState is expanded the proper code is shown there. Running the code at this point will panic otherwise. --- book/src/chapter_7.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/book/src/chapter_7.md b/book/src/chapter_7.md index e01fd065..9d1dca36 100644 --- a/book/src/chapter_7.md +++ b/book/src/chapter_7.md @@ -614,7 +614,7 @@ Now we modify the `monster_ai_system`. There's a bit of clean-up here, and the " ```rust use specs::prelude::*; -use super::{Viewshed, Monster, Map, Position, WantsToMelee, RunState}; +use super::{Viewshed, Monster, Map, Position, WantsToMelee}; use rltk::{Point}; pub struct MonsterAI {} @@ -624,7 +624,6 @@ impl<'a> System<'a> for MonsterAI { type SystemData = ( WriteExpect<'a, Map>, ReadExpect<'a, Point>, ReadExpect<'a, Entity>, - ReadExpect<'a, RunState>, Entities<'a>, WriteStorage<'a, Viewshed>, ReadStorage<'a, Monster>, @@ -632,7 +631,7 @@ impl<'a> System<'a> for MonsterAI { WriteStorage<'a, WantsToMelee>); fn run(&mut self, data : Self::SystemData) { - let (mut map, player_pos, player_entity, runstate, entities, mut viewshed, monster, mut position, mut wants_to_melee) = data; + let (mut map, player_pos, player_entity, entities, mut viewshed, monster, mut position, mut wants_to_melee) = data; for (entity, mut viewshed,_monster,mut pos) in (&entities, &mut viewshed, &monster, &mut position).join() { let distance = rltk::DistanceAlg::Pythagoras.distance2d(Point::new(pos.x, pos.y), *player_pos);