diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index a212ca9e4b..4ec867e9b2 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -98,22 +98,7 @@ namespace Content.Server.GameObjects "Clothing must be passed here. To remove some clothing from a slot, use Unequip()"); } - var pass = false; - - if (item is ClothingComponent clothing) - { - if (clothing.SlotFlags != SlotFlags.PREVENTEQUIP && (clothing.SlotFlags & SlotMasks[slot]) != 0) - { - pass = true; - } - } - - if (Owner.TryGetComponent(out IInventoryController controller)) - { - pass = controller.CanEquip(slot, item.Owner, pass); - } - - if (!pass) + if (!CanEquip(slot, item)) { return false; } @@ -130,17 +115,37 @@ namespace Content.Server.GameObjects return true; } + public bool Equip(Slots slot, IEntity entity) => Equip(slot, entity.GetComponent()); + + /// /// Checks whether an item can be put in the specified slot. /// /// The slot to check for. /// The item to check for. /// True if the item can be inserted into the specified slot. - public bool CanEquip(Slots slot, ClothingComponent item) + public bool CanEquip(Slots slot, ItemComponent item) { - return SlotContainers[slot].CanInsert(item.Owner); + var pass = false; + + if (item is ClothingComponent clothing) + { + if (clothing.SlotFlags != SlotFlags.PREVENTEQUIP && (clothing.SlotFlags & SlotMasks[slot]) != 0) + { + pass = true; + } + } + + if (Owner.TryGetComponent(out IInventoryController controller)) + { + pass = controller.CanEquip(slot, item.Owner, pass); + } + + return pass && SlotContainers[slot].CanInsert(item.Owner); } + public bool CanEquip(Slots slot, IEntity entity) => CanEquip(slot, entity.GetComponent()); + /// /// Drops the item in a slot. ///