]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Belt and back slot quick draw (#14828)
authorTyzemol <85772526+Tyzemol@users.noreply.github.com>
Sun, 26 Mar 2023 23:01:09 +0000 (04:01 +0500)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2023 23:01:09 +0000 (16:01 -0700)
* backgunquickequip

* backgunquickequip

* fix build fail

* fix build fail 2

* cleanup

---------

Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
Content.Server/Hands/Systems/HandsSystem.cs

index 59a653b2aecf7a0259dbf9b28edd9be1df5de52f..3848b00dfd08310d47fa6d3d9f75b22f74f3b91b 100644 (file)
@@ -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;
             }