sorry - swapping from rustfmt to prettier-rust
This commit is contained in:
parent
281396f9ce
commit
c2c7e0bd52
93 changed files with 2797 additions and 2021 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Chasing, EntityMoved, Map, Position, TakingTurn, Telepath, Viewshed};
|
||||
use crate::{ Chasing, EntityMoved, Map, Position, TakingTurn, Telepath, Viewshed };
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -48,20 +48,24 @@ impl<'a> System<'a> for ChaseAI {
|
|||
// stored in the HashMap. If successful, follow the path. If not, remove
|
||||
// the chasing component.
|
||||
let mut turn_done: Vec<Entity> = Vec::new();
|
||||
for (entity, _turn, mut pos, _chase, mut viewshed) in
|
||||
(&entities, &turns, &mut positions, &chasing, &mut viewsheds).join()
|
||||
{
|
||||
for (entity, _turn, mut pos, _chase, mut viewshed) in (
|
||||
&entities,
|
||||
&turns,
|
||||
&mut positions,
|
||||
&chasing,
|
||||
&mut viewsheds,
|
||||
).join() {
|
||||
turn_done.push(entity);
|
||||
let target_pos = targets[&entity];
|
||||
let path = a_star_search(
|
||||
map.xy_idx(pos.x, pos.y) as i32,
|
||||
map.xy_idx(target_pos.0, target_pos.1) as i32,
|
||||
&mut *map,
|
||||
&mut *map
|
||||
);
|
||||
if path.success && path.steps.len() > 1 && path.steps.len() < MAX_CHASE_DISTANCE {
|
||||
let idx = map.xy_idx(pos.x, pos.y);
|
||||
pos.x = path.steps[1] as i32 % map.width;
|
||||
pos.y = path.steps[1] as i32 / map.width;
|
||||
pos.x = (path.steps[1] as i32) % map.width;
|
||||
pos.y = (path.steps[1] as i32) / map.width;
|
||||
entity_moved.insert(entity, EntityMoved {}).expect("Failed to insert EntityMoved");
|
||||
let new_idx = map.xy_idx(pos.x, pos.y);
|
||||
crate::spatial::move_entity(entity, idx, new_idx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue