From: Tyzemol <85772526+Tyzemol@users.noreply.github.com> Date: Sun, 26 Mar 2023 23:01:09 +0000 (+0500) Subject: Belt and back slot quick draw (#14828) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6476474205483de8a5156228b38825775ef2f819;p=space-station-14.git Belt and back slot quick draw (#14828) * backgunquickequip * backgunquickequip * fix build fail * fix build fail 2 * cleanup --------- Co-authored-by: BuildTools --- diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 59a653b2ae..3848b00dfd 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -254,6 +254,31 @@ namespace Content.Server.Hands.Systems 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; }