diff --git a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs
index d85958a8fb..79d6c804f7 100644
--- a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs
+++ b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs
@@ -56,6 +56,10 @@ namespace Content.Server.Disposal.Unit.Components
[ViewVariables]
public Direction CurrentDirection { get; set; } = Direction.Invalid;
+ /// Mistake prevention
+ [ViewVariables]
+ public bool IsExitingDisposals { get; set; } = false;
+
///
/// A list of tags attached to the content, used for sorting
///
diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs
index 494503097a..c596e61e5f 100644
--- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs
+++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs
@@ -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;
}
}