Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out multiple enemy messages moving to the same location #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions WinningAndLosing/gauntlet/src/systems/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod random_move;
mod chasing;
mod end_turn;
mod movement;
mod movement_filter;
mod hud;
mod tooltips;
mod combat;
Expand Down Expand Up @@ -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())
Expand Down
20 changes: 20 additions & 0 deletions WinningAndLosing/gauntlet/src/systems/movement_filter.rs
Original file line number Diff line number Diff line change
@@ -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<Point> = 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);
}
});
}