CatStation/Content.Shared/Stunnable/SharedStunbatonSystem.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

33 lines
1.1 KiB
C#

using Content.Shared.ActionBlocker;
using Content.Shared.Item.ItemToggle.Components;
namespace Content.Shared.Stunnable;
public abstract partial class SharedStunbatonSystem : EntitySystem
{
[Dependency] private ActionBlockerSystem _actionBlocker = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StunbatonComponent, ItemToggleActivateAttemptEvent>(TryTurnOn);
SubscribeLocalEvent<StunbatonComponent, ItemToggleDeactivateAttemptEvent>(TryTurnOff);
}
protected virtual void TryTurnOn(Entity<StunbatonComponent> entity, ref ItemToggleActivateAttemptEvent args)
{
if (args.User != null && !_actionBlocker.CanComplexInteract(args.User.Value)) {
args.Cancelled = true;
return;
}
}
protected virtual void TryTurnOff(Entity<StunbatonComponent> entity, ref ItemToggleDeactivateAttemptEvent args)
{
if (args.User != null && !_actionBlocker.CanComplexInteract(args.User.Value)) {
args.Cancelled = true;
return;
}
}
}