IntervalSpawningSystem{} fix, and mobs randomly move
This commit is contained in:
parent
5276bb6e34
commit
b5e3880a33
5 changed files with 61 additions and 28 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use super::{EntityMoved, Map, Monster, Position, TakingTurn, Viewshed, WantsToMelee};
|
||||
use super::{bystander_ai_system, EntityMoved, Map, Monster, Position, TakingTurn, Viewshed, WantsToMelee};
|
||||
use rltk::Point;
|
||||
use specs::prelude::*;
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ impl<'a> System<'a> for MonsterAI {
|
|||
#[allow(clippy::type_complexity)]
|
||||
type SystemData = (
|
||||
WriteExpect<'a, Map>,
|
||||
WriteExpect<'a, rltk::RandomNumberGenerator>,
|
||||
ReadExpect<'a, Point>,
|
||||
ReadExpect<'a, Entity>,
|
||||
Entities<'a>,
|
||||
|
|
@ -22,6 +23,7 @@ impl<'a> System<'a> for MonsterAI {
|
|||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (
|
||||
mut map,
|
||||
mut rng,
|
||||
player_pos,
|
||||
player_entity,
|
||||
entities,
|
||||
|
|
@ -57,6 +59,10 @@ impl<'a> System<'a> for MonsterAI {
|
|||
viewshed.dirty = true;
|
||||
entity_moved.insert(entity, EntityMoved {}).expect("Unable to insert marker");
|
||||
}
|
||||
} else {
|
||||
if bystander_ai_system::try_move_randomly(&mut pos, &mut rng, &mut map, &mut viewshed) {
|
||||
entity_moved.insert(entity, EntityMoved {}).expect("Unable to insert marker");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue