[][src]Function veloren_common::comp::inventory::slot::equip

pub fn equip(slot: usize, inventory: &mut Inventory, loadout: &mut Loadout)

Equip an item from a slot in inventory. The currently equipped item will go into inventory. If the item is going to mainhand, put mainhand in offhand and place offhand into inventory.

use veloren_common::{
    assets,
    comp::{
        slot::{equip, EquipSlot},
        Inventory, Item,
    },
    LoadoutBuilder,
};

let boots: Option<Item> = Some(assets::load_expect_cloned(
    "common.items.testing.test_boots",
));

let mut inv = Inventory {
    slots: vec![boots.clone()],
    amount: 1,
};

let mut loadout = LoadoutBuilder::new().defaults().build();

equip(0, &mut inv, &mut loadout);
assert_eq!(boots, loadout.foot);