24 lines
690 B
C#
24 lines
690 B
C#
|
|
using Content.Shared.Containers.ItemSlots;
|
||
|
|
using Content.Shared.Power.Components;
|
||
|
|
|
||
|
|
namespace Content.Shared.Power.EntitySystems;
|
||
|
|
|
||
|
|
public sealed class ItemSlotRequiresPowerSystem : EntitySystem
|
||
|
|
{
|
||
|
|
[Dependency] private readonly 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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|