Prevent drag and dropping if the user is currenly unable to perform interactions. (fixes #5144) (#5196)

This commit is contained in:
Antoine Chavasse
2021-11-07 01:05:51 +01:00
committed by GitHub
parent a4bdfd2b52
commit afeb22ccb2
2 changed files with 10 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Content.Client.State;
using Content.Client.Viewport;
using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
@@ -37,6 +38,7 @@ namespace Content.Client.DragDrop
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
// how often to recheck possible targets (prevents calling expensive
// check logic each update)
@@ -413,6 +415,11 @@ namespace Content.Client.DragDrop
/// <returns>null if the target doesn't support IDragDropOn</returns>
private bool? ValidDragDrop(DragDropEvent eventArgs)
{
if (!_actionBlockerSystem.CanInteract(eventArgs.User))
{
return false;
}
bool? valid = null;
foreach (var comp in eventArgs.Target.GetAllComponents<IDragDropOn>())