fix: respect AllowedSlots for gogo hat (#39189)

This commit is contained in:
Perry Fraser
2026-01-08 14:25:43 -05:00
committed by GitHub
parent 019268b056
commit e4ac948dec
2 changed files with 15 additions and 4 deletions

View 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

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