Fix disposals trapping you for eternity when leaving via a trunk pipe (#5498)
This commit is contained in:
@@ -56,6 +56,10 @@ namespace Content.Server.Disposal.Unit.Components
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public Direction CurrentDirection { get; set; } = Direction.Invalid;
|
public Direction CurrentDirection { get; set; } = Direction.Invalid;
|
||||||
|
|
||||||
|
/// <summary>Mistake prevention</summary>
|
||||||
|
[ViewVariables]
|
||||||
|
public bool IsExitingDisposals { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of tags attached to the content, used for sorting
|
/// A list of tags attached to the content, used for sorting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Robust.Shared.Containers;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
|
|
||||||
@@ -25,6 +26,12 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
|||||||
{
|
{
|
||||||
if (!Resolve(uid, ref holder, ref holderTransform))
|
if (!Resolve(uid, ref holder, ref holderTransform))
|
||||||
return;
|
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.
|
// 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.*
|
// *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))
|
if (!Resolve(holderUid, ref holder, ref holderTransform))
|
||||||
return false;
|
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))
|
if (!Resolve(toUid, ref to, ref toTransform))
|
||||||
{
|
{
|
||||||
ExitDisposals(holderUid, holder, holderTransform);
|
ExitDisposals(holderUid, holder, holderTransform);
|
||||||
@@ -102,19 +114,19 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
|||||||
holder.PreviousTube = holder.CurrentTube;
|
holder.PreviousTube = holder.CurrentTube;
|
||||||
holder.PreviousDirection = holder.CurrentDirection;
|
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!
|
// Invalid direction = exit now!
|
||||||
if (dir == Direction.Invalid)
|
if (holder.CurrentDirection == Direction.Invalid)
|
||||||
{
|
{
|
||||||
ExitDisposals(holderUid, holder, holderTransform);
|
ExitDisposals(holderUid, holder, holderTransform);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
holderTransform.Coordinates = toTransform.Coordinates;
|
|
||||||
holder.CurrentTube = to;
|
|
||||||
holder.CurrentDirection = dir;
|
|
||||||
holder.StartingTime = 0.1f;
|
|
||||||
holder.TimeLeft = 0.1f;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +185,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
|||||||
// Perform remainder of entry process
|
// Perform remainder of entry process
|
||||||
if (!EnterTube(holder.OwnerUid, nextTube.OwnerUid, holder, null, nextTube, null))
|
if (!EnterTube(holder.OwnerUid, nextTube.OwnerUid, holder, null, nextTube, null))
|
||||||
{
|
{
|
||||||
ExitDisposals(holder.OwnerUid);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user