1
0

ItemSlotRequiresPowerSystem.cs 690 B

1234567891011121314151617181920212223
  1. using Content.Shared.Containers.ItemSlots;
  2. using Content.Shared.Power.Components;
  3. namespace Content.Shared.Power.EntitySystems;
  4. public sealed class ItemSlotRequiresPowerSystem : EntitySystem
  5. {
  6. [Dependency] private readonly SharedPowerReceiverSystem _receiver = default!;
  7. public override void Initialize()
  8. {
  9. base.Initialize();
  10. SubscribeLocalEvent<ItemSlotRequiresPowerComponent, ItemSlotInsertAttemptEvent>(OnInsertAttempt);
  11. }
  12. private void OnInsertAttempt(Entity<ItemSlotRequiresPowerComponent> ent, ref ItemSlotInsertAttemptEvent args)
  13. {
  14. if (!_receiver.IsPowered(ent.Owner))
  15. {
  16. args.Cancelled = true;
  17. }
  18. }
  19. }