initial commit
using rltk
This commit is contained in:
parent
40a2ac07be
commit
d3a09df7a8
29 changed files with 3323 additions and 0 deletions
26
src/map_indexing_system.rs
Normal file
26
src/map_indexing_system.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use super::{BlocksTile, Map, Position};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct MapIndexingSystem {}
|
||||
|
||||
impl<'a> System<'a> for MapIndexingSystem {
|
||||
type SystemData = (WriteExpect<'a, Map>, ReadStorage<'a, Position>, ReadStorage<'a, BlocksTile>, Entities<'a>);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (mut map, position, blockers, entities) = data;
|
||||
|
||||
map.populate_blocked();
|
||||
map.clear_content_index();
|
||||
for (entity, position) in (&entities, &position).join() {
|
||||
let idx = map.xy_idx(position.x, position.y);
|
||||
|
||||
let _p: Option<&BlocksTile> = blockers.get(entity);
|
||||
if let Some(_p) = _p {
|
||||
map.blocked[idx] = true;
|
||||
}
|
||||
|
||||
// Push the entity to the appropriate index slot.
|
||||
map.tile_content[idx].push(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue