2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Interaction;
|
2020-08-30 11:37:06 +02:00
|
|
|
|
using Content.Shared.Physics;
|
|
|
|
|
|
using Robust.Client.Player;
|
2021-03-01 15:24:46 -08:00
|
|
|
|
using Robust.Shared.Containers;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-08-30 11:37:06 +02:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Map;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using static Content.Shared.Interaction.SharedInteractionSystem;
|
2020-08-30 11:37:06 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Interactable
|
2020-08-30 11:37:06 +02:00
|
|
|
|
{
|
2020-10-11 13:13:45 +02:00
|
|
|
|
public static class UnobstructedExtensions
|
2020-08-30 11:37:06 +02:00
|
|
|
|
{
|
|
|
|
|
|
private static SharedInteractionSystem SharedInteractionSystem => EntitySystem.Get<SharedInteractionSystem>();
|
|
|
|
|
|
|
|
|
|
|
|
public static bool InRangeUnobstructed(
|
|
|
|
|
|
this LocalPlayer origin,
|
|
|
|
|
|
IEntity other,
|
|
|
|
|
|
float range = InteractionRange,
|
|
|
|
|
|
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
2021-03-10 14:48:29 +01:00
|
|
|
|
Ignored? predicate = null,
|
2020-08-30 11:37:06 +02:00
|
|
|
|
bool ignoreInsideBlocker = false,
|
|
|
|
|
|
bool popup = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
var otherPosition = other.Transform.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,
|
2021-03-10 14:48:29 +01:00
|
|
|
|
Ignored? predicate = null,
|
2020-08-30 11:37:06 +02:00
|
|
|
|
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,
|
2021-03-10 14:48:29 +01:00
|
|
|
|
Ignored? predicate = null,
|
2020-08-30 11:37:06 +02:00
|
|
|
|
bool ignoreInsideBlocker = false,
|
|
|
|
|
|
bool popup = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return origin.InRangeUnobstructed(other.Owner, range, collisionMask, predicate, ignoreInsideBlocker, popup);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool InRangeUnobstructed(
|
|
|
|
|
|
this LocalPlayer origin,
|
2020-09-06 16:11:53 +02:00
|
|
|
|
EntityCoordinates other,
|
2020-08-30 11:37:06 +02:00
|
|
|
|
float range = InteractionRange,
|
|
|
|
|
|
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
2021-03-10 14:48:29 +01:00
|
|
|
|
Ignored? predicate = null,
|
2020-08-30 11:37:06 +02:00
|
|
|
|
bool ignoreInsideBlocker = false,
|
|
|
|
|
|
bool popup = false)
|
|
|
|
|
|
{
|
2020-09-06 16:11:53 +02:00
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
var otherPosition = other.ToMap(entityManager);
|
2020-08-30 11:37:06 +02:00
|
|
|
|
|
|
|
|
|
|
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,
|
2021-03-10 14:48:29 +01:00
|
|
|
|
Ignored? predicate = null,
|
2020-08-30 11:37:06 +02:00
|
|
|
|
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, other, range, collisionMask, predicate,
|
|
|
|
|
|
ignoreInsideBlocker, popup);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|