Fix disposals trapping you for eternity when leaving via a trunk pipe (#5498)

This commit is contained in:
20kdc
2021-11-25 02:10:15 +00:00
committed by GitHub
parent fab19cd4ea
commit de0a6511cc
2 changed files with 24 additions and 9 deletions

View File

@@ -56,6 +56,10 @@ namespace Content.Server.Disposal.Unit.Components
[ViewVariables]
public Direction CurrentDirection { get; set; } = Direction.Invalid;
/// <summary>Mistake prevention</summary>
[ViewVariables]
public bool IsExitingDisposals { get; set; } = false;
/// <summary>
/// A list of tags attached to the content, used for sorting
/// </summary>

View File

@@ -9,6 +9,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
@@ -25,6 +26,12 @@ namespace Content.Server.Disposal.Unit.EntitySystems
{
if (!Resolve(uid, ref holder, ref holderTransform))
return;
if (holder.IsExitingDisposals)
{
Logger.ErrorS("c.s.disposal.holder", "Tried exiting disposals twice. This should never happen.");
return;
}
holder.IsExitingDisposals = true;
// Check for a disposal unit to throw them into and then eject them from it.
// *This ejection also makes the target not collide with the unit.*
@@ -83,6 +90,11 @@ namespace Content.Server.Disposal.Unit.EntitySystems
{
if (!Resolve(holderUid, ref holder, ref holderTransform))
return false;
if (holder.IsExitingDisposals)
{
Logger.ErrorS("c.s.disposal.holder", "Tried entering tube after exiting disposals. This should never happen.");
return false;
}
if (!Resolve(toUid, ref to, ref toTransform))
{
ExitDisposals(holderUid, holder, holderTransform);
@@ -102,19 +114,19 @@ namespace Content.Server.Disposal.Unit.EntitySystems
holder.PreviousTube = holder.CurrentTube;
holder.PreviousDirection = holder.CurrentDirection;
}
var dir = to.NextDirection(holder);
holderTransform.Coordinates = toTransform.Coordinates;
holder.CurrentTube = to;
holder.CurrentDirection = to.NextDirection(holder);
holder.StartingTime = 0.1f;
holder.TimeLeft = 0.1f;
// Logger.InfoS("c.s.disposal.holder", $"Disposals dir {holder.CurrentDirection}");
// Invalid direction = exit now!
if (dir == Direction.Invalid)
if (holder.CurrentDirection == Direction.Invalid)
{
ExitDisposals(holderUid, holder, holderTransform);
return false;
}
holderTransform.Coordinates = toTransform.Coordinates;
holder.CurrentTube = to;
holder.CurrentDirection = dir;
holder.StartingTime = 0.1f;
holder.TimeLeft = 0.1f;
return true;
}
@@ -173,7 +185,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems
// Perform remainder of entry process
if (!EnterTube(holder.OwnerUid, nextTube.OwnerUid, holder, null, nextTube, null))
{
ExitDisposals(holder.OwnerUid);
break;
}
}