2025-06-02 13:06:45 -04:00
|
|
|
using Content.Shared.ActionBlocker;
|
|
|
|
|
using Content.Shared.Item.ItemToggle.Components;
|
|
|
|
|
|
2023-08-08 23:19:31 +03:00
|
|
|
namespace Content.Shared.Stunnable;
|
|
|
|
|
|
|
|
|
|
public abstract class SharedStunbatonSystem : EntitySystem
|
|
|
|
|
{
|
2025-06-02 13:06:45 -04:00
|
|
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
|
|
|
|
|
2023-08-08 23:19:31 +03:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2025-06-02 13:06:45 -04:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2023-08-08 23:19:31 +03:00
|
|
|
}
|
|
|
|
|
}
|