mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-18 22:51:11 +03:00
* 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
33 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|