using Content.Shared._Goobstation.Wires.Components; using Content.Shared.Containers.ItemSlots; using Content.Shared.Wires; namespace Content.Shared._Goobstation.Wires.Systems; public sealed partial class RequirePanelSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(ItemSlotInsertAttempt); SubscribeLocalEvent(ItemSlotEjectAttempt); } private void ItemSlotInsertAttempt(Entity entity, ref ItemSlotInsertAttemptEvent args) => args.Cancelled = !CheckPanelStateForItemSlot(entity, args.Slot.ID); private void ItemSlotEjectAttempt(Entity entity, ref ItemSlotEjectAttemptEvent args) => args.Cancelled = !CheckPanelStateForItemSlot(entity, args.Slot.ID); public bool CheckPanelStateForItemSlot(Entity entity, string? slot) { var (uid, comp) = entity; if (slot == null // If slot doesn't require a wire panel - don't cancel interaction || !comp.Slots.TryGetValue(slot, out var isRequireOpen) || !TryComp(uid, out var wiresPanel)) return false; return wiresPanel.Open == isRequireOpen; } }