]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix: respect AllowedSlots for gogo hat (#39189)
authorPerry Fraser <perryprog@users.noreply.github.com>
Thu, 8 Jan 2026 19:25:43 +0000 (14:25 -0500)
committerGitHub <noreply@github.com>
Thu, 8 Jan 2026 19:25:43 +0000 (19:25 +0000)
Content.Server/VoiceTrigger/StorageVoiceControlSystem.cs
Content.Shared/Inventory/InventorySystem.Helpers.cs

index ade861af981821348e4f002b12b3cdf3ea93d688..7b58278d08f4d37fe39468bf14a728db5bf97a45 100644 (file)
@@ -30,10 +30,9 @@ public sealed class StorageVoiceControlSystem : EntitySystem
 
     private void VoiceTriggered(Entity<StorageVoiceControlComponent> ent, ref VoiceTriggeredEvent args)
     {
-        // Check if the component has any slot restrictions via AllowedSlots
         // If it has slot restrictions, check if the item is in a slot that is allowed
-        if (ent.Comp.AllowedSlots != null && _inventory.TryGetContainingSlot(ent.Owner, out var itemSlot) &&
-            (itemSlot.SlotFlags & ent.Comp.AllowedSlots) == 0)
+        if (ent.Comp.AllowedSlots is { } allowedSlots
+            && !_inventory.InSlotWithAnyFlags(ent.Owner, allowedSlots))
             return;
 
         // Get the storage component
index 259c3b6c8df2a6395b71814ca72d7045e32f42f9..4c56a5da439514a5ba5d63afcaef110aa93f6c68 100644 (file)
@@ -47,14 +47,26 @@ public partial class InventorySystem
     }
 
     /// <summary>
-    ///     Returns true if the given entity is equipped to an inventory slot with the given inventory slot flags.
+    /// Returns true if the given entity is equipped to an inventory slot with exactly matching inventory slot flags.
     /// </summary>
+    /// <seealso cref="InSlotWithAnyFlags" />
     public bool InSlotWithFlags(Entity<TransformComponent?, MetaDataComponent?> entity, SlotFlags flags)
     {
         return TryGetContainingSlot(entity, out var slot)
                && (slot.SlotFlags & flags) == flags;
     }
 
+    /// <summary>
+    /// Returns true if the given entity is equipped to an inventory slot that
+    /// has any flags in common with the given ones.
+    /// </summary>
+    /// <seealso cref="InSlotWithFlags" />
+    public bool InSlotWithAnyFlags(Entity<TransformComponent?, MetaDataComponent?> ent, SlotFlags flags)
+    {
+        return TryGetContainingSlot(ent, out var slot)
+               && (slot.SlotFlags & flags) != 0;
+    }
+
     public bool SpawnItemInSlot(EntityUid uid, string slot, string prototype, bool silent = false, bool force = false, InventoryComponent? inventory = null)
     {
         if (!Resolve(uid, ref inventory, false))