Skip to content

Commit

Permalink
feat(system): Allow player to only have one weapon
Browse files Browse the repository at this point in the history
This makes the game a bit more challenging!
  • Loading branch information
yngtdd committed Apr 10, 2022
1 parent 356113d commit eb4fc7b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/systems/player_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::prelude::*;
#[read_component(Enemy)]
#[read_component(Item)]
#[read_component(Carried)]
#[read_component(Weapon)]
#[write_component(Health)]
pub fn player_input(
ecs: &mut SubWorld,
Expand Down Expand Up @@ -34,6 +35,17 @@ pub fn player_input(
.for_each(|(entity, _item, _item_pos)| {
commands.remove_component::<Point>(*entity);
commands.add_component(*entity, Carried(player));

if let Ok(e) = ecs.entry_ref(*entity) {
if e.get_component::<Weapon>().is_ok() {
<(Entity, &Carried, &Weapon)>::query()
.iter(ecs)
.filter(|(_, c, _)| c.0 == player)
.for_each(|(e, _, _)| {
commands.remove(*e);
})
}
}
});
Point::new(0, 0)
}
Expand Down

0 comments on commit eb4fc7b

Please sign in to comment.