Actually use InventoryComponent.CanEquip from Equip.
This commit is contained in:
@@ -98,22 +98,7 @@ namespace Content.Server.GameObjects
|
|||||||
"Clothing must be passed here. To remove some clothing from a slot, use Unequip()");
|
"Clothing must be passed here. To remove some clothing from a slot, use Unequip()");
|
||||||
}
|
}
|
||||||
|
|
||||||
var pass = false;
|
if (!CanEquip(slot, item))
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -130,17 +115,37 @@ namespace Content.Server.GameObjects
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Equip(Slots slot, IEntity entity) => Equip(slot, entity.GetComponent<ItemComponent>());
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks whether an item can be put in the specified slot.
|
/// Checks whether an item can be put in the specified slot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="slot">The slot to check for.</param>
|
/// <param name="slot">The slot to check for.</param>
|
||||||
/// <param name="item">The item 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>
|
/// <returns>True if the item can be inserted into the specified slot.</returns>
|
||||||
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<ItemComponent>());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops the item in a slot.
|
/// Drops the item in a slot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user