Prevent borgs from getting duplicate modules (#28943)

* Prevent borgs from getting duplicate modules

* outta the loop

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
This commit is contained in:
Plykiya
2024-06-14 19:58:30 -07:00
committed by GitHub
parent 3cd740c32b
commit 835d1dd153
2 changed files with 21 additions and 1 deletions

View 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;
}

View 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.