Beginning the conversion to an Effects system
This commit is contained in:
parent
a6690029e6
commit
efe15705ad
13 changed files with 382 additions and 67 deletions
33
src/spatial/map_indexing_system.rs
Normal file
33
src/spatial/map_indexing_system.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
use crate::{spatial, BlocksTile, Map, Pools, Position};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct MapIndexingSystem {}
|
||||
|
||||
impl<'a> System<'a> for MapIndexingSystem {
|
||||
type SystemData = (
|
||||
ReadExpect<'a, Map>,
|
||||
ReadStorage<'a, Position>,
|
||||
ReadStorage<'a, BlocksTile>,
|
||||
Entities<'a>,
|
||||
ReadStorage<'a, Pools>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (map, position, blockers, entities, pools) = data;
|
||||
|
||||
spatial::clear();
|
||||
spatial::populate_blocked_from_map(&*map);
|
||||
for (entity, position) in (&entities, &position).join() {
|
||||
let mut alive = true;
|
||||
if let Some(pools) = pools.get(entity) {
|
||||
if pools.hit_points.current < 1 {
|
||||
alive = false;
|
||||
}
|
||||
}
|
||||
if alive {
|
||||
let idx = map.xy_idx(position.x, position.y);
|
||||
spatial::index_entity(entity, idx, blockers.get(entity).is_some());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,9 @@ use crate::{tile_walkable, Map, RunState};
|
|||
use specs::prelude::*;
|
||||
use std::sync::Mutex;
|
||||
|
||||
mod map_indexing_system;
|
||||
pub use map_indexing_system::MapIndexingSystem;
|
||||
|
||||
struct SpatialMap {
|
||||
blocked: Vec<(bool, bool)>,
|
||||
tile_content: Vec<Vec<(Entity, bool)>>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue