]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
suit storage whitelist code (#29332)
authorErrant <35878406+Errant-4@users.noreply.github.com>
Fri, 28 Jun 2024 15:11:43 +0000 (17:11 +0200)
committerGitHub <noreply@github.com>
Fri, 28 Jun 2024 15:11:43 +0000 (11:11 -0400)
suit storage whitelist

Content.Shared/Armor/AllowSuitStorageComponent.cs
Content.Shared/Inventory/InventorySystem.Equip.cs

index aa7bce1c8734188d5ca0af043ac9c61c9aebbbfc..23ddd8963493994607ecd9b0ac79fe0ce1e98e01 100644 (file)
@@ -1,3 +1,5 @@
+using Content.Shared.Whitelist;
+
 namespace Content.Shared.Armor;
 
 /// <summary>
@@ -6,5 +8,12 @@ namespace Content.Shared.Armor;
 [RegisterComponent]
 public sealed partial class AllowSuitStorageComponent : Component
 {
-
+    /// <summary>
+    /// Whitelist for what entities are allowed in the suit storage slot.
+    /// </summary>
+    [DataField]
+    public EntityWhitelist Whitelist = new()
+    {
+        Components = new[] {"Item"}
+    };
 }
index 7acfafee4a639a5a5d1760f68c08957db3e2fda6..324d6a7af029a8b0d219dd3b11473157bd7d7b1f 100644 (file)
@@ -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<AllowSuitStorageComponent>(slotEntity, out var comp) &&
+                        _whitelistSystem.IsWhitelistFailOrNull(comp.Whitelist, itemUid))
+                        return false;
+                }
+            }
         }
 
         var fittingInPocket = slotDefinition.SlotFlags.HasFlag(SlotFlags.POCKET) &&