using Content.Shared.Inventory.Events; namespace Content.Shared.Inventory; /// /// Handles prevention of items being unequipped and equipped from slots that are blocked by . /// public sealed partial class SlotBlockSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent>(OnEquipAttempt); SubscribeLocalEvent>(OnUnequipAttempt); } private void OnEquipAttempt(Entity ent, ref InventoryRelayedEvent args) { if (args.Args.Cancelled || (args.Args.SlotFlags & ent.Comp.Slots) == 0) return; args.Args.Reason = Loc.GetString("slot-block-component-blocked", ("item", ent)); args.Args.Cancel(); } private void OnUnequipAttempt(Entity ent, ref InventoryRelayedEvent args) { if (args.Args.Cancelled || (args.Args.SlotFlags & ent.Comp.Slots) == 0) return; args.Args.Reason = Loc.GetString("slot-block-component-blocked", ("item", ent)); args.Args.Cancel(); } }