/// <summary> /// Equips slothing to the specified slot. /// </summary> /// <remarks> /// This will fail if there is already an item in the specified slot. /// </remarks> /// <param name="slot">The slot to put the item in.</param> /// <param name="clothing">The item to insert into the slot.</param> /// <returns>True if the item was successfully inserted, false otherwise.</returns> public bool Equip(Slots slot, ClothingComponent clothing) { if (clothing == null) { throw new ArgumentNullException(nameof(clothing), "Clothing must be passed here. To remove some clothing from a slot, use Unequip()"); } if (clothing.SlotFlags == SlotFlags.PREVENTEQUIP || //Flag to prevent equipping at all (clothing.SlotFlags & SlotMasks[slot]) == 0 ) //Does the clothing flag have any of our requested slot flags { return(false); } var inventorySlot = SlotContainers[slot]; if (!inventorySlot.Insert(clothing.Owner)) { return(false); } clothing.EquippedToSlot(); Dirty(); return(true); }
/// <summary> /// Equips slothing to the specified slot. /// </summary> /// <remarks> /// This will fail if there is already an item in the specified slot. /// </remarks> /// <param name="slot">The slot to put the item in.</param> /// <param name="clothing">The item to insert into the slot.</param> /// <returns>True if the item was successfully inserted, false otherwise.</returns> public bool Equip(Slots slot, ClothingComponent clothing) { if (clothing == null) { throw new ArgumentNullException(nameof(clothing), "Clothing must be passed here. To remove some clothing from a slot, use Unequip()"); } if (clothing.SlotFlags == SlotFlags.PREVENTEQUIP || //Flag to prevent equipping at all (clothing.SlotFlags & SlotMasks[slot]) == 0) //Does the clothing flag have any of our requested slot flags { return(false); } var inventorySlot = SlotContainers[slot]; if (!inventorySlot.Insert(clothing.Owner)) { return(false); } clothing.EquippedToSlot(inventorySlot); var UIupdatemessage = new ServerInventoryMessage() { Inventoryslot = slot, EntityUid = clothing.Owner.Uid, Updatetype = ServerInventoryUpdate.Addition }; SendNetworkMessage(UIupdatemessage); return(true); }
/// <summary> /// Checks whether an item can be put in the specified slot. /// </summary> /// <param name="slot">The slot to check for.</param> /// <param name="item">The item to check for.</param> /// <returns>True if the item can be inserted into the specified slot.</returns> public bool CanEquip(Slots slot, ClothingComponent item) { return(SlotContainers[slot].CanInsert(item.Owner)); }