CatStation/Content.Shared/Power/EntitySystems/ItemSlotRequiresPowerSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

23 lines
689 B
C#

using Content.Shared.Containers.ItemSlots;
using Content.Shared.Power.Components;
namespace Content.Shared.Power.EntitySystems;
public sealed partial class ItemSlotRequiresPowerSystem : EntitySystem
{
[Dependency] private SharedPowerReceiverSystem _receiver = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ItemSlotRequiresPowerComponent, ItemSlotInsertAttemptEvent>(OnInsertAttempt);
}
private void OnInsertAttempt(Entity<ItemSlotRequiresPowerComponent> ent, ref ItemSlotInsertAttemptEvent args)
{
if (!_receiver.IsPowered(ent.Owner))
{
args.Cancelled = true;
}
}
}