Fix interact using sometimes having target==used (#6847)
This commit is contained in:
@@ -4,6 +4,7 @@ using JetBrains.Annotations;
|
|||||||
using Robust.Shared.Analyzers;
|
using Robust.Shared.Analyzers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.Interaction
|
namespace Content.Shared.Interaction
|
||||||
{
|
{
|
||||||
@@ -78,6 +79,11 @@ namespace Content.Shared.Interaction
|
|||||||
|
|
||||||
public InteractUsingEvent(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation, bool predicted = false)
|
public InteractUsingEvent(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation, bool predicted = false)
|
||||||
{
|
{
|
||||||
|
// Interact using should not have the same used and target.
|
||||||
|
// That should be a use-in-hand event instead.
|
||||||
|
// If this is not the case, can lead to bugs (e.g., attempting to merge a item stack into itself).
|
||||||
|
DebugTools.Assert(used != target);
|
||||||
|
|
||||||
User = user;
|
User = user;
|
||||||
Used = used;
|
Used = used;
|
||||||
Target = target;
|
Target = target;
|
||||||
|
|||||||
@@ -216,6 +216,12 @@ namespace Content.Shared.Interaction
|
|||||||
if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user))
|
if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (target == hand.HeldEntity)
|
||||||
|
{
|
||||||
|
UseInHandInteraction(user, target.Value, checkCanUse: false, checkCanInteract: false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (inRangeUnobstructed && target != null)
|
if (inRangeUnobstructed && target != null)
|
||||||
{
|
{
|
||||||
InteractUsing(
|
InteractUsing(
|
||||||
|
|||||||
Reference in New Issue
Block a user