Files
Delta-v/Content.Shared/Stunnable/SharedStunbatonSystem.cs
slarticodefast 50b2986ef7 Predict powercells, chargers and PowerCellDraw (#41379)
* cleanup

* fix fixtures

* prediction

* fix test

* review

* fix svalinn visuals

* fix chargers

* fix portable recharger and its unlit visuals

* fix borgs

* oomba review

* fix examination prediction
2026-01-26 19:25:30 +01:00

34 lines
1.1 KiB
C#

using Content.Shared.ActionBlocker;
using Content.Shared.Item.ItemToggle.Components;
namespace Content.Shared.Stunnable;
public abstract class SharedStunbatonSystem : EntitySystem
{
[Dependency] private readonly 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;
}
}
}