Changed how lantern swap is caught

This commit is contained in:
ninefox 2022-01-23 10:34:06 -08:00
parent 973b392e38
commit 04b0277e33

View File

@ -427,14 +427,16 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
comp::InventoryManip::Swap(a, b) => {
let ecs = state.ecs();
if let (Slot::Inventory(inv_slot), Slot::Equip(slot::EquipSlot::Lantern))
| (Slot::Equip(slot::EquipSlot::Lantern), Slot::Inventory(inv_slot)) = (a, b)
{
if let Some(comp::item::ItemKind::Lantern(lantern)) =
inventory.get(inv_slot).map(|item| item.kind())
{
swap_lantern(&mut ecs.write_storage(), entity, lantern);
}
if let Some(comp::item::ItemKind::Lantern(lantern)) = match (a, b) {
// Only current possible lantern swap is between Slot::Inventory and Slot::Equip
// add more cases if needed
(Slot::Equip(slot::EquipSlot::Lantern), Slot::Inventory(slot))
| (Slot::Inventory(slot), Slot::Equip(slot::EquipSlot::Lantern)) => {
inventory.get(slot).map(|item| item.kind())
},
_ => None,
} {
swap_lantern(&mut ecs.write_storage(), entity, lantern);
}
if let Some(pos) = ecs.read_storage::<comp::Pos>().get(entity) {