Remove ignore-inside-blocker (#6692)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,20 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Construction
|
||||
@@ -27,6 +21,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
|
||||
private readonly Dictionary<int, ConstructionGhostComponent> _ghosts = new();
|
||||
private readonly Dictionary<string, ConstructionGuide> _guideCache = new();
|
||||
@@ -162,8 +157,12 @@ namespace Content.Client.Construction
|
||||
return;
|
||||
}
|
||||
|
||||
if (GhostPresent(loc)) return;
|
||||
|
||||
// This InRangeUnobstructed should probably be replaced with "is there something blocking us in that tile?"
|
||||
if (GhostPresent(loc) || !user.InRangeUnobstructed(loc, 20f, ignoreInsideBlocker: prototype.CanBuildInImpassable)) return;
|
||||
var predicate = GetPredicate(prototype.CanBuildInImpassable, loc.ToMap(EntityManager));
|
||||
if (!_interactionSystem.InRangeUnobstructed(user, loc, 20f, predicate: predicate))
|
||||
return;
|
||||
|
||||
foreach (var condition in prototype.Conditions)
|
||||
{
|
||||
|
||||
@@ -297,19 +297,6 @@ namespace Content.Client.DragDrop
|
||||
return false;
|
||||
}
|
||||
|
||||
// now when ending the drag, we will not replay the click because
|
||||
// by this time we've determined the input was actually a drag attempt
|
||||
var range = (args.Coordinates.ToMapPos(EntityManager) - EntityManager.GetComponent<TransformComponent>(_dragger).MapPosition.Position).Length + 0.01f;
|
||||
// tell the server we are dropping if we are over a valid drop target in range.
|
||||
// We don't use args.EntityUid here because drag interactions generally should
|
||||
// work even if there's something "on top" of the drop target
|
||||
if (!_interactionSystem.InRangeUnobstructed(_dragger,
|
||||
args.Coordinates, range, ignoreInsideBlocker: true))
|
||||
{
|
||||
_dragDropHelper.EndDrag();
|
||||
return false;
|
||||
}
|
||||
|
||||
IList<EntityUid> entities;
|
||||
|
||||
if (_stateManager.CurrentState is GameScreen screen)
|
||||
@@ -333,7 +320,8 @@ namespace Content.Client.DragDrop
|
||||
// TODO: Cache valid CanDragDrops
|
||||
if (ValidDragDrop(dropArgs) != true) continue;
|
||||
|
||||
if (!dropArgs.InRangeUnobstructed(ignoreInsideBlocker: true))
|
||||
if (!_interactionSystem.InRangeUnobstructed(dropArgs.User, dropArgs.Target)
|
||||
|| !_interactionSystem.InRangeUnobstructed(dropArgs.User, dropArgs.Dragged))
|
||||
{
|
||||
outOfRange = true;
|
||||
continue;
|
||||
@@ -401,7 +389,8 @@ namespace Content.Client.DragDrop
|
||||
// We'll do a final check given server-side does this before any dragdrop can take place.
|
||||
if (valid.Value)
|
||||
{
|
||||
valid = dropArgs.InRangeUnobstructed(ignoreInsideBlocker: true);
|
||||
valid = _interactionSystem.InRangeUnobstructed(dropArgs.Target, dropArgs.Dragged)
|
||||
&& _interactionSystem.InRangeUnobstructed(dropArgs.Target, dropArgs.Target);
|
||||
}
|
||||
|
||||
// highlight depending on whether its in or out of range
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Interactable;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Client.Audio.Midi;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Player;
|
||||
@@ -151,8 +152,7 @@ namespace Content.Client.Instruments.UI
|
||||
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
||||
|
||||
// We check that we're in range unobstructed just in case.
|
||||
return localPlayer.InRangeUnobstructed(instrumentEnt.Value,
|
||||
predicate: (e) => e == instrumentEnt || e == localPlayer.ControlledEntity);
|
||||
return EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(localPlayer.ControlledEntity.Value, instrumentEnt.Value);
|
||||
}
|
||||
|
||||
private void MidiStopButtonOnPressed(ButtonEventArgs? obj)
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using static Content.Shared.Interaction.SharedInteractionSystem;
|
||||
|
||||
namespace Content.Client.Interactable
|
||||
{
|
||||
public static class UnobstructedExtensions
|
||||
{
|
||||
private static SharedInteractionSystem SharedInteractionSystem => EntitySystem.Get<SharedInteractionSystem>();
|
||||
|
||||
public static bool InRangeUnobstructed(
|
||||
this LocalPlayer origin,
|
||||
EntityUid other,
|
||||
float range = InteractionRange,
|
||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
||||
Ignored? predicate = null,
|
||||
bool ignoreInsideBlocker = false,
|
||||
bool popup = false)
|
||||
{
|
||||
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other).MapPosition;
|
||||
|
||||
return origin.InRangeUnobstructed(otherPosition, range, collisionMask, predicate, ignoreInsideBlocker,
|
||||
popup);
|
||||
}
|
||||
|
||||
public static bool InRangeUnobstructed(
|
||||
this LocalPlayer origin,
|
||||
IComponent other,
|
||||
float range = InteractionRange,
|
||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
||||
Ignored? predicate = null,
|
||||
bool ignoreInsideBlocker = false,
|
||||
bool popup = false)
|
||||
{
|
||||
return origin.InRangeUnobstructed(other.Owner, range, collisionMask, predicate, ignoreInsideBlocker, popup);
|
||||
}
|
||||
|
||||
public static bool InRangeUnobstructed(
|
||||
this LocalPlayer origin,
|
||||
IContainer other,
|
||||
float range = InteractionRange,
|
||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
||||
Ignored? predicate = null,
|
||||
bool ignoreInsideBlocker = false,
|
||||
bool popup = false)
|
||||
{
|
||||
return origin.InRangeUnobstructed(other.Owner, range, collisionMask, predicate, ignoreInsideBlocker, popup);
|
||||
}
|
||||
|
||||
public static bool InRangeUnobstructed(
|
||||
this LocalPlayer origin,
|
||||
EntityCoordinates other,
|
||||
float range = InteractionRange,
|
||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
||||
Ignored? predicate = null,
|
||||
bool ignoreInsideBlocker = false,
|
||||
bool popup = false)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var otherPosition = other.ToMap(entityManager);
|
||||
|
||||
return origin.InRangeUnobstructed(otherPosition, range, collisionMask, predicate, ignoreInsideBlocker,
|
||||
popup);
|
||||
}
|
||||
|
||||
public static bool InRangeUnobstructed(
|
||||
this LocalPlayer origin,
|
||||
MapCoordinates other,
|
||||
float range = InteractionRange,
|
||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
||||
Ignored? predicate = null,
|
||||
bool ignoreInsideBlocker = false,
|
||||
bool popup = false)
|
||||
{
|
||||
var originEntity = origin.ControlledEntity;
|
||||
if (originEntity == null)
|
||||
{
|
||||
// TODO: Take into account the player's camera position?
|
||||
return false;
|
||||
}
|
||||
|
||||
return SharedInteractionSystem.InRangeUnobstructed(originEntity.Value, other, range, collisionMask, predicate,
|
||||
ignoreInsideBlocker, popup);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Climbing;
|
||||
using Content.Shared.Climbing;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -19,7 +20,10 @@ namespace Content.Client.Movement.Components
|
||||
var dragged = eventArgs.Dragged;
|
||||
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged;
|
||||
|
||||
return user.InRangeUnobstructed(target, Range, predicate: Ignored) && user.InRangeUnobstructed(dragged, Range, predicate: Ignored);
|
||||
var sys = EntitySystem.Get<SharedInteractionSystem>();
|
||||
|
||||
return sys.InRangeUnobstructed(user, target, Range, predicate: Ignored)
|
||||
&& sys.InRangeUnobstructed(user, dragged, Range, predicate: Ignored);
|
||||
}
|
||||
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Client.Interactable;
|
||||
using Content.Client.Interactable.Components;
|
||||
using Content.Client.Viewport;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
@@ -10,8 +11,6 @@ using Robust.Client.State;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Outline;
|
||||
|
||||
@@ -23,6 +22,7 @@ public sealed class InteractionOutlineSystem : EntitySystem
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
|
||||
public bool Enabled = true;
|
||||
|
||||
@@ -76,7 +76,7 @@ public sealed class InteractionOutlineSystem : EntitySystem
|
||||
var inRange = false;
|
||||
if (localPlayer.ControlledEntity != null && entityToClick != null)
|
||||
{
|
||||
inRange = localPlayer.InRangeUnobstructed(entityToClick.Value, ignoreInsideBlocker: true);
|
||||
inRange = _interactionSystem.InRangeUnobstructed(localPlayer.ControlledEntity.Value, entityToClick.Value);
|
||||
}
|
||||
|
||||
InteractionOutlineComponent? outline;
|
||||
|
||||
Reference in New Issue
Block a user