Refactor InRangeUnobstructed and add extension methods (#1925)

* Sort out InRangeUnobstructed and add extension methods

* Rename client RangeChecks to RangeExtensions

* Add container extension methods and test

* Add missing component methods

Component to container
Grid coordinates to container
Map coordinates to container
Local player to container

* Actually use the field

* Merge fixes

* Add popup argument to local player extension methods

* Reduce code repetition for client range extensions
This commit is contained in:
DrSmugleaf
2020-08-30 11:37:06 +02:00
committed by GitHub
parent 9ec3ddf368
commit 9d6c394f6b
39 changed files with 1287 additions and 359 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
@@ -43,18 +44,10 @@ namespace Content.Server.GameObjects.Components.Medical
return;
}
if (eventArgs.User != eventArgs.Target)
if (eventArgs.User != eventArgs.Target &&
!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
{
var interactionSystem = EntitySystem.Get<SharedInteractionSystem>();
var from = eventArgs.User.Transform.MapPosition;
var to = eventArgs.Target.Transform.MapPosition;
bool Ignored(IEntity entity) => entity == eventArgs.User || entity == eventArgs.Target;
var inRange = interactionSystem.InRangeUnobstructed(from, to, predicate: Ignored);
if (!inRange)
{
return;
}
return;
}
if (Owner.TryGetComponent(out StackComponent stack) &&