diff --git a/WinningAndLosing/gauntlet/src/systems/mod.rs b/WinningAndLosing/gauntlet/src/systems/mod.rs index 1222bf2..5850038 100644 --- a/WinningAndLosing/gauntlet/src/systems/mod.rs +++ b/WinningAndLosing/gauntlet/src/systems/mod.rs @@ -7,6 +7,7 @@ mod random_move; mod chasing; mod end_turn; mod movement; +mod movement_filter; mod hud; mod tooltips; mod combat; @@ -42,6 +43,8 @@ pub fn build_monster_scheduler() -> Schedule { .flush() .add_system(combat::combat_system()) .flush() + .add_system(movement_filter::movement_filter_system()) + .flush() .add_system(movement::movement_system()) .flush() .add_system(map_render::map_render_system()) diff --git a/WinningAndLosing/gauntlet/src/systems/movement_filter.rs b/WinningAndLosing/gauntlet/src/systems/movement_filter.rs new file mode 100644 index 0000000..63c8eb4 --- /dev/null +++ b/WinningAndLosing/gauntlet/src/systems/movement_filter.rs @@ -0,0 +1,20 @@ +use crate::prelude::*; + +#[system] +#[read_component(WantsToMove)] +pub fn movement_filter( + ecs: &mut SubWorld, + commands: &mut CommandBuffer) { + + let mut moves = <(Entity, &WantsToMove)>::query(); + let mut pos_seen: Vec = Vec::new(); + + moves.iter(ecs).for_each(|(entity, want_move)| { + if pos_seen.contains(&want_move.destination) { + commands.remove(*entity); + } + else { + pos_seen.push(want_move.destination); + } + }); +} \ No newline at end of file