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:
@@ -4,6 +4,7 @@ using Content.Shared.GameObjects.Components.Strap;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
@@ -202,14 +203,9 @@ namespace Content.Server.GameObjects.Components.Strap
|
||||
parent = parent.Parent;
|
||||
}
|
||||
|
||||
var userPosition = user.Transform.MapPosition;
|
||||
var strapPosition = component.Owner.Transform.MapPosition;
|
||||
var range = SharedInteractionSystem.InteractionRange / 2;
|
||||
var inRange = EntitySystem.Get<SharedInteractionSystem>()
|
||||
.InRangeUnobstructed(userPosition, strapPosition, range,
|
||||
predicate: entity => entity == user || entity == component.Owner);
|
||||
|
||||
if (!inRange)
|
||||
if (!user.InRangeUnobstructed(component, range))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user