if (!_inventorySystem.TryGetSlotEntity(plyEnt, equipmentSlot, out var slotEntity) ||
!TryComp(slotEntity, out ServerStorageComponent? storageComponent))
{
+ if (_inventorySystem.HasSlot(plyEnt, equipmentSlot))
+ {
+ if (hands.ActiveHand.HeldEntity == null && slotEntity != null)
+ {
+ _inventorySystem.TryUnequip(plyEnt, equipmentSlot);
+ PickupOrDrop(plyEnt, slotEntity.Value);
+ return;
+ }
+ if (hands.ActiveHand.HeldEntity == null)
+ return;
+ if (!_inventorySystem.CanEquip(plyEnt, hands.ActiveHand.HeldEntity.Value, equipmentSlot, out var reason))
+ {
+ _popupSystem.PopupEntity(Loc.GetString(reason), plyEnt, session);
+ return;
+ }
+ if (slotEntity == null)
+ {
+ _inventorySystem.TryEquip(plyEnt, hands.ActiveHand.HeldEntity.Value, equipmentSlot);
+ return;
+ }
+ _inventorySystem.TryUnequip(plyEnt, equipmentSlot);
+ _inventorySystem.TryEquip(plyEnt, hands.ActiveHand.HeldEntity.Value, equipmentSlot);
+ PickupOrDrop(plyEnt, slotEntity.Value);
+ return;
+ }
_popupSystem.PopupEntity(Loc.GetString("hands-system-missing-equipment-slot", ("slotName", equipmentSlot)), plyEnt, session);
return;
}