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

@@ -16,6 +16,7 @@ using Content.Shared.GameObjects.Components.ActionBlocking;
using Content.Server.GameObjects.Components.Mobs;
using Robust.Shared.Maths;
using System;
using Content.Shared.Utility;
namespace Content.Server.GameObjects.Components.ActionBlocking
{
@@ -115,7 +116,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
private float _interactRange;
private DoAfterSystem _doAfterSystem;
private AudioSystem _audioSystem;
public override void Initialize()
{
base.Initialize();
@@ -182,11 +183,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
return;
}
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(
eventArgs.User.Transform.MapPosition,
eventArgs.Target.Transform.MapPosition,
_interactRange,
ignoredEnt: Owner))
if (!eventArgs.InRangeUnobstructed(_interactRange, ignoreInsideBlocker: true))
{
_notifyManager.PopupMessage(eventArgs.User, eventArgs.User, Loc.GetString("You are too far away to use the cuffs!"));
return;
@@ -196,7 +193,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
_notifyManager.PopupMessage(eventArgs.User, eventArgs.Target, Loc.GetString("{0:theName} starts cuffing you!", eventArgs.User));
_audioSystem.PlayFromEntity(StartCuffSound, Owner);
TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed);
TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed);
}
/// <summary>