mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
fix: respect AllowedSlots for gogo hat (#39189)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user