diff options
| author | troido <troido@protonmail.com> | 2020-04-13 22:32:41 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-13 22:32:41 +0200 |
| commit | 0245cc348ae77eda77e06019fbf07f4f8b8cb82a (patch) | |
| tree | fa94945b42e4baa6ae529b1b12184dbbbc8e74d3 /src | |
| parent | ed84fb58e25efed952d0c874fde5232fbb26f45b (diff) | |
using an equipped item unequips it
Diffstat (limited to 'src')
| -rw-r--r-- | src/systems/useitem.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/systems/useitem.rs b/src/systems/useitem.rs index 605f083..485b1da 100644 --- a/src/systems/useitem.rs +++ b/src/systems/useitem.rs @@ -57,15 +57,19 @@ impl <'a> System<'a> for Use { inventory.items.remove(*rank); } Equip(equippable) => { - let slot = equippable.slot; - for otherentry in inventory.items.iter_mut() { - if let Equip(other) = &otherentry.item.action { - if other.slot == slot { - otherentry.is_equipped = false; + if entry.is_equipped { + inventory.items[*rank].is_equipped = false; + } else { + let slot = equippable.slot; + for otherentry in inventory.items.iter_mut() { + if let Equip(other) = &otherentry.item.action { + if other.slot == slot { + otherentry.is_equipped = false; + } } } + inventory.items[*rank].is_equipped = true; } - inventory.items[*rank].is_equipped = true; } None => {} } |
