Fix being able to buckle through a locker and reality collapsing

This commit is contained in:
DrSmugleaf
2020-07-03 14:54:45 +02:00
parent 3ee480a3b1
commit dd72c1e3f0
11 changed files with 60 additions and 37 deletions

View File

@@ -9,6 +9,7 @@ using Content.Shared.GameObjects.Components.Strap;
using Content.Shared.GameObjects.EntitySystems;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
@@ -59,6 +60,22 @@ namespace Content.Server.GameObjects.Components.Mobs
}
}
private bool IsContained()
{
var parent = Owner.Transform.Parent;
if (parent == null)
{
return false;
}
if (parent.Owner.TryGetComponent(out ContainerManagerComponent container))
{
return container.ContainsEntity(Owner);
}
return false;
}
private bool TryBuckle(IEntity user, IEntity to)
{
if (user == null || user == to)
@@ -76,7 +93,8 @@ namespace Content.Server.GameObjects.Components.Mobs
var strapPosition = Owner.Transform.MapPosition;
var range = SharedInteractionSystem.InteractionRange / 2;
if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range))
if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range) ||
IsContained())
{
_notifyManager.PopupMessage(user, user,
Loc.GetString("You can't reach there!"));