Fix whipping input

This commit is contained in:
Alex Page 2022-11-27 19:39:10 -05:00
parent 74d1c120fc
commit 4b0b67c69a

View file

@ -2,7 +2,7 @@ use instant::Instant;
use std::time::Duration;
use bracket_lib::prelude::*;
use hecs::{Entity, With, Without, World};
use hecs::{Entity, Without, World};
use crate::{
components::monster::*,
@ -16,7 +16,9 @@ use crate::{
pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut Resources) {
let mut to_kill: Vec<Entity> = Vec::new();
for (player_entity, (player, pos)) in &mut world.query::<Without<(&mut Player, &mut Position), &WantsToWhip>>() {
for (player_entity, (player, pos)) in
&mut world.query::<Without<(&mut Player, &mut Position), &WantsToWhip>>()
{
let now = Instant::now();
if now - player.last_moved > Duration::from_secs_f32(PLAYER_STEP_PERIOD) {
let destination = Point {
@ -271,7 +273,7 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
pub fn whip(world: &mut World, resources: &mut Resources) {
let mut to_add: Vec<Entity> = Vec::new();
for (entity, _) in world.query_mut::<With<&Player, With<&Position, Without<&WantsToWhip, ()>>>>() {
for (entity, _) in world.query_mut::<Without<(&Player, &Position), &WantsToWhip>>() {
if resources.stats.whips > 0 {
to_add.push(entity);
}