Fix whipping input
This commit is contained in:
parent
74d1c120fc
commit
4b0b67c69a
1 changed files with 5 additions and 3 deletions
|
@ -2,7 +2,7 @@ use instant::Instant;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use bracket_lib::prelude::*;
|
use bracket_lib::prelude::*;
|
||||||
use hecs::{Entity, With, Without, World};
|
use hecs::{Entity, Without, World};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::monster::*,
|
components::monster::*,
|
||||||
|
@ -16,7 +16,9 @@ use crate::{
|
||||||
pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut Resources) {
|
pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut Resources) {
|
||||||
let mut to_kill: Vec<Entity> = Vec::new();
|
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();
|
let now = Instant::now();
|
||||||
if now - player.last_moved > Duration::from_secs_f32(PLAYER_STEP_PERIOD) {
|
if now - player.last_moved > Duration::from_secs_f32(PLAYER_STEP_PERIOD) {
|
||||||
let destination = Point {
|
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) {
|
pub fn whip(world: &mut World, resources: &mut Resources) {
|
||||||
let mut to_add: Vec<Entity> = Vec::new();
|
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 {
|
if resources.stats.whips > 0 {
|
||||||
to_add.push(entity);
|
to_add.push(entity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue