From: Errant <35878406+Errant-4@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:11:43 +0000 (+0200) Subject: suit storage whitelist code (#29332) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=9e4b8077f3295931556e7b1892f6b2ddcd9d7ab6;p=space-station-14.git suit storage whitelist code (#29332) suit storage whitelist --- diff --git a/Content.Shared/Armor/AllowSuitStorageComponent.cs b/Content.Shared/Armor/AllowSuitStorageComponent.cs index aa7bce1c87..23ddd89634 100644 --- a/Content.Shared/Armor/AllowSuitStorageComponent.cs +++ b/Content.Shared/Armor/AllowSuitStorageComponent.cs @@ -1,3 +1,5 @@ +using Content.Shared.Whitelist; + namespace Content.Shared.Armor; /// @@ -6,5 +8,12 @@ namespace Content.Shared.Armor; [RegisterComponent] public sealed partial class AllowSuitStorageComponent : Component { - + /// + /// Whitelist for what entities are allowed in the suit storage slot. + /// + [DataField] + public EntityWhitelist Whitelist = new() + { + Components = new[] {"Item"} + }; } diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 7acfafee4a..324d6a7af0 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -248,9 +248,17 @@ public abstract partial class InventorySystem return false; if (slotDefinition.DependsOnComponents is { } componentRegistry) + { foreach (var (_, entry) in componentRegistry) + { if (!HasComp(slotEntity, entry.Component.GetType())) return false; + + if (TryComp(slotEntity, out var comp) && + _whitelistSystem.IsWhitelistFailOrNull(comp.Whitelist, itemUid)) + return false; + } + } } var fittingInPocket = slotDefinition.SlotFlags.HasFlag(SlotFlags.POCKET) &&