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:
@@ -37,7 +37,9 @@ namespace Content.Server.Rotatable
|
||||
|
||||
private void AddFlipVerb(EntityUid uid, FlippableComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
if (!args.CanAccess
|
||||
|| !args.CanInteract
|
||||
|| !args.CanComplexInteract)
|
||||
return;
|
||||
|
||||
// Check if the object is anchored.
|
||||
@@ -60,6 +62,7 @@ namespace Content.Server.Rotatable
|
||||
{
|
||||
if (!args.CanAccess
|
||||
|| !args.CanInteract
|
||||
|| !args.CanComplexInteract
|
||||
|| Transform(uid).NoLocalRotation) // Good ol prototype inheritance, eh?
|
||||
return;
|
||||
|
||||
@@ -125,7 +128,9 @@ namespace Content.Server.Rotatable
|
||||
if (!TryComp<RotatableComponent>(entity, out var rotatableComp))
|
||||
return false;
|
||||
|
||||
if (!_actionBlocker.CanInteract(player, entity) || !_interaction.InRangeAndAccessible(player, entity))
|
||||
if (!_actionBlocker.CanInteract(player, entity)
|
||||
|| !_actionBlocker.CanComplexInteract(player)
|
||||
|| !_interaction.InRangeAndAccessible(player, entity))
|
||||
return false;
|
||||
|
||||
// Check if the object is anchored, and whether we are still allowed to rotate it.
|
||||
@@ -148,7 +153,9 @@ namespace Content.Server.Rotatable
|
||||
if (!TryComp<RotatableComponent>(entity, out var rotatableComp))
|
||||
return false;
|
||||
|
||||
if (!_actionBlocker.CanInteract(player, entity) || !_interaction.InRangeAndAccessible(player, entity))
|
||||
if (!_actionBlocker.CanInteract(player, entity)
|
||||
|| !_actionBlocker.CanComplexInteract(player)
|
||||
|| !_interaction.InRangeAndAccessible(player, entity))
|
||||
return false;
|
||||
|
||||
// Check if the object is anchored, and whether we are still allowed to rotate it.
|
||||
@@ -171,7 +178,9 @@ namespace Content.Server.Rotatable
|
||||
if (!TryComp<FlippableComponent>(entity, out var flippableComp))
|
||||
return false;
|
||||
|
||||
if (!_actionBlocker.CanInteract(player, entity) || !_interaction.InRangeAndAccessible(player, entity))
|
||||
if (!_actionBlocker.CanInteract(player, entity)
|
||||
|| !_actionBlocker.CanComplexInteract(player)
|
||||
|| !_interaction.InRangeAndAccessible(player, entity))
|
||||
return false;
|
||||
|
||||
// Check if the object is anchored.
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
|
||||
private void OnActivate(EntityUid uid, EmitterComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
if (args.Handled || !args.Complex)
|
||||
return;
|
||||
|
||||
if (TryComp(uid, out LockComponent? lockComp) && lockComp.Locked)
|
||||
@@ -101,7 +101,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
|
||||
private void OnGetVerb(EntityUid uid, EmitterComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
||||
if (!args.CanAccess || !args.CanInteract || !args.CanComplexInteract || args.Hands == null)
|
||||
return;
|
||||
|
||||
if (TryComp<LockComponent>(uid, out var lockComp) && lockComp.Locked)
|
||||
|
||||
@@ -68,6 +68,9 @@ public sealed class RadiationCollectorSystem : EntitySystem
|
||||
|
||||
private void OnActivate(EntityUid uid, RadiationCollectorComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (!args.Complex)
|
||||
return;
|
||||
|
||||
if (TryComp(uid, out UseDelayComponent? useDelay) && !_useDelay.TryResetDelay((uid, useDelay), true))
|
||||
return;
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Content.Server.Stunnable.Systems
|
||||
SubscribeLocalEvent<StunbatonComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<StunbatonComponent, SolutionContainerChangedEvent>(OnSolutionChange);
|
||||
SubscribeLocalEvent<StunbatonComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
|
||||
SubscribeLocalEvent<StunbatonComponent, ItemToggleActivateAttemptEvent>(TryTurnOn);
|
||||
SubscribeLocalEvent<StunbatonComponent, ChargeChangedEvent>(OnChargeChanged);
|
||||
}
|
||||
|
||||
@@ -52,8 +51,10 @@ namespace Content.Server.Stunnable.Systems
|
||||
}
|
||||
}
|
||||
|
||||
private void TryTurnOn(Entity<StunbatonComponent> entity, ref ItemToggleActivateAttemptEvent args)
|
||||
protected override void TryTurnOn(Entity<StunbatonComponent> entity, ref ItemToggleActivateAttemptEvent args)
|
||||
{
|
||||
base.TryTurnOn(entity, ref args);
|
||||
|
||||
if (!TryComp<BatteryComponent>(entity, out var battery) || battery.CurrentCharge < entity.Comp.EnergyPerUse)
|
||||
{
|
||||
args.Cancelled = true;
|
||||
|
||||
@@ -92,7 +92,7 @@ public sealed class SurveillanceCameraRouterSystem : EntitySystem
|
||||
|
||||
private void AddVerbs(EntityUid uid, SurveillanceCameraRouterComponent component, GetVerbsEvent<AlternativeVerb> verbs)
|
||||
{
|
||||
if (!_actionBlocker.CanInteract(verbs.User, uid))
|
||||
if (!_actionBlocker.CanInteract(verbs.User, uid) || !_actionBlocker.CanComplexInteract(verbs.User))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public sealed class SurveillanceCameraSystem : EntitySystem
|
||||
|
||||
private void AddVerbs(EntityUid uid, SurveillanceCameraComponent component, GetVerbsEvent<AlternativeVerb> verbs)
|
||||
{
|
||||
if (!_actionBlocker.CanInteract(verbs.User, uid))
|
||||
if (!_actionBlocker.CanInteract(verbs.User, uid) || !_actionBlocker.CanComplexInteract(verbs.User))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user