Add more instrument interaction checks (#9223)
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Client.Interactable;
|
using Content.Client.Interactable;
|
||||||
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Robust.Client.Audio.Midi;
|
using Robust.Client.Audio.Midi;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
@@ -132,6 +133,8 @@ namespace Content.Client.Instruments.UI
|
|||||||
|
|
||||||
private bool PlayCheck()
|
private bool PlayCheck()
|
||||||
{
|
{
|
||||||
|
// TODO all of these checks should also be done server-side.
|
||||||
|
|
||||||
var instrumentEnt = _owner.Instrument?.Owner;
|
var instrumentEnt = _owner.Instrument?.Owner;
|
||||||
var instrument = _owner.Instrument;
|
var instrument = _owner.Instrument;
|
||||||
|
|
||||||
@@ -151,8 +154,12 @@ namespace Content.Client.Instruments.UI
|
|||||||
if ((instrument.Handheld && (conMan == null
|
if ((instrument.Handheld && (conMan == null
|
||||||
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
||||||
|
|
||||||
|
var entSysMan = IoCManager.Resolve<IEntitySystemManager>();
|
||||||
|
if (!entSysMan.GetEntitySystem<ActionBlockerSystem>().CanInteract(localPlayer.ControlledEntity.Value, instrumentEnt))
|
||||||
|
return false;
|
||||||
|
|
||||||
// We check that we're in range unobstructed just in case.
|
// We check that we're in range unobstructed just in case.
|
||||||
return EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(localPlayer.ControlledEntity.Value, instrumentEnt.Value);
|
return entSysMan.GetEntitySystem<SharedInteractionSystem>().InRangeUnobstructed(localPlayer.ControlledEntity.Value, instrumentEnt.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MidiStopButtonOnPressed(ButtonEventArgs? obj)
|
private void MidiStopButtonOnPressed(ButtonEventArgs? obj)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.Administration.Managers;
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Ghost.Components;
|
using Content.Server.Ghost.Components;
|
||||||
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
@@ -15,6 +16,7 @@ namespace Content.Server.UserInterface
|
|||||||
internal sealed class ActivatableUISystem : EntitySystem
|
internal sealed class ActivatableUISystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
|
[Dependency] private readonly ActionBlockerSystem _blockerSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -66,6 +68,9 @@ namespace Content.Server.UserInterface
|
|||||||
if (!args.CanAccess)
|
if (!args.CanAccess)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (component.RequireHands && args.Hands == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (component.InHandsOnly && args.Using != uid)
|
if (component.InHandsOnly && args.Using != uid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -106,6 +111,12 @@ namespace Content.Server.UserInterface
|
|||||||
|
|
||||||
private bool InteractUI(EntityUid user, ActivatableUIComponent aui)
|
private bool InteractUI(EntityUid user, ActivatableUIComponent aui)
|
||||||
{
|
{
|
||||||
|
if (!_blockerSystem.CanInteract(user, aui.Owner) && (!aui.AllowSpectator || !HasComp<GhostComponent>(user)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (aui.RequireHands && !HasComp<SharedHandsComponent>(user))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(user, out ActorComponent? actor)) return false;
|
if (!EntityManager.TryGetComponent(user, out ActorComponent? actor)) return false;
|
||||||
|
|
||||||
if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession)) return false;
|
if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession)) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user