Add checks for various complex interactions (#37246)
* Prevent toggling radiation collectors * Prevent resisting locks * Prevent unbuckling others, early exit before doafter * Prevent camera and camera router setup * Prevent rotating and flipping * Also prevent adding the unbuckle verb. * Revert ResistLocker changes * Prevent emitter tampering * Also prevent lock verb * Prevent toggling welders * Prevent gun open/close bolt, rack and switch mode * Prevent toggling stun batons
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Database;
|
||||
@@ -12,6 +13,8 @@ namespace Content.Shared.Tools.Systems;
|
||||
|
||||
public abstract partial class SharedToolSystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||
|
||||
public void InitializeWelder()
|
||||
{
|
||||
SubscribeLocalEvent<WelderComponent, ExaminedEvent>(OnWelderExamine);
|
||||
@@ -27,6 +30,7 @@ public abstract partial class SharedToolSystem
|
||||
|
||||
SubscribeLocalEvent<WelderComponent, ItemToggledEvent>(OnToggle);
|
||||
SubscribeLocalEvent<WelderComponent, ItemToggleActivateAttemptEvent>(OnActivateAttempt);
|
||||
SubscribeLocalEvent<WelderComponent, ItemToggleDeactivateAttemptEvent>(OnDeactivateAttempt);
|
||||
}
|
||||
|
||||
public void TurnOn(Entity<WelderComponent> entity, EntityUid? user)
|
||||
@@ -165,6 +169,11 @@ public abstract partial class SharedToolSystem
|
||||
|
||||
private void OnActivateAttempt(Entity<WelderComponent> entity, ref ItemToggleActivateAttemptEvent args)
|
||||
{
|
||||
if (args.User != null && !_actionBlocker.CanComplexInteract(args.User.Value)) {
|
||||
args.Cancelled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SolutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.FuelSolutionName, out _, out var solution))
|
||||
{
|
||||
args.Cancelled = true;
|
||||
@@ -179,4 +188,12 @@ public abstract partial class SharedToolSystem
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDeactivateAttempt(Entity<WelderComponent> entity, ref ItemToggleDeactivateAttemptEvent args)
|
||||
{
|
||||
if (args.User != null && !_actionBlocker.CanComplexInteract(args.User.Value)) {
|
||||
args.Cancelled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user