complete spatial indexing refactor - SpatialMap

This commit is contained in:
Llywelwyn 2023-08-16 01:17:38 +01:00
parent 2887bb9736
commit d439ff6d3f
18 changed files with 351 additions and 217 deletions

View file

@ -39,13 +39,12 @@ impl<'a> System<'a> for ApproachAI {
&mut *map,
);
if path.success && path.steps.len() > 1 {
let mut idx = map.xy_idx(pos.x, pos.y);
map.blocked[idx] = false;
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;
entity_moved.insert(entity, EntityMoved {}).expect("Unable to insert EntityMoved");
idx = map.xy_idx(pos.x, pos.y);
map.blocked[idx] = true;
let new_idx = map.xy_idx(pos.x, pos.y);
crate::spatial::move_entity(entity, idx, new_idx);
viewshed.dirty = true;
if let Some(telepath) = telepaths.get_mut(entity) {
telepath.dirty = true;