]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Prevent borgs from getting duplicate modules (#28943)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Sat, 15 Jun 2024 02:58:30 +0000 (19:58 -0700)
committerGitHub <noreply@github.com>
Sat, 15 Jun 2024 02:58:30 +0000 (22:58 -0400)
* Prevent borgs from getting duplicate modules

* outta the loop

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
Content.Server/Silicons/Borgs/BorgSystem.Modules.cs
Resources/Locale/en-US/borg/borg.ftl

index 5c600be3f6404eb2c4109e70f437f495d0d41850..f372f7df1a50d8d7e927c8d2687203c96d4d8a30 100644 (file)
@@ -274,6 +274,25 @@ public sealed partial class BorgSystem
             return false;
         }
 
+        if (TryComp<ItemBorgModuleComponent>(module, out var itemModuleComp))
+        {
+            foreach (var containedModuleUid in component.ModuleContainer.ContainedEntities)
+            {
+                if (!TryComp<ItemBorgModuleComponent>(containedModuleUid, out var containedItemModuleComp))
+                    continue;
+
+                for (int i = 0; i < itemModuleComp.Items.Count; i++)
+                {
+                    if (itemModuleComp.Items[i] != containedItemModuleComp.Items[i])
+                        continue;
+                }
+
+                if (user != null)
+                    Popup.PopupEntity(Loc.GetString("borg-module-duplicate"), uid, user.Value);
+                return false;
+            }
+        }
+
         return true;
     }
 
index c9005eb7961792ac83d67f5cac821a56277d0f71..72667f318e353cc6ca605744cf7905c1aeb0dfb4 100644 (file)
@@ -1,4 +1,4 @@
-borg-player-not-allowed = The brain doesn't fit!
+borg-player-not-allowed = The brain doesn't fit!
 borg-player-not-allowed-eject = The brain was expelled from the chassis!
 
 borg-panel-not-open = The cyborg's panel isn't open...
@@ -7,6 +7,7 @@ borg-mind-added = {CAPITALIZE($name)} powered on!
 borg-mind-removed = {CAPITALIZE($name)} shut off!
 
 borg-module-too-many = There's not enough room for another module...
+borg-module-duplicate = This module is already installed in this cyborg.
 borg-module-whitelist-deny = This module doesn't fit in this type of cyborg...
 
 borg-construction-guide-string = The cyborg limbs and torso must be attached to the endoskeleton.