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:
@@ -3,6 +3,7 @@ using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Server.AI.Operators.Inventory
|
||||
@@ -50,7 +51,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
if (!InteractionChecks.InRangeUnobstructed(_owner, _target.Transform.MapPosition))
|
||||
if (!_owner.InRangeUnobstructed(_target, popup: true))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.EntitySystems.Click;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!InteractionChecks.InRangeUnobstructed(_owner, _useTarget.Transform.MapPosition))
|
||||
if (!_owner.InRangeUnobstructed(_useTarget, popup: true))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.AI.WorldState.States.Inventory;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
@@ -30,7 +31,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Success;
|
||||
}
|
||||
|
||||
if (!InteractionChecks.InRangeUnobstructed(_owner, container.Owner.Transform.MapPosition, ignoredEnt: container.Owner))
|
||||
if (!_owner.InRangeUnobstructed(container, popup: true))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.EntitySystems.Click;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -26,7 +27,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
if (_target.Deleted ||
|
||||
!_target.HasComponent<ItemComponent>() ||
|
||||
ContainerHelpers.IsInContainer(_target) ||
|
||||
!InteractionChecks.InRangeUnobstructed(_owner, _target.Transform.MapPosition))
|
||||
!_owner.InRangeUnobstructed(_target, popup: true))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user