Disposals fixed under station rotation (#5067)

* Some sanity checks on disposals movement, fix the interpolator

* Technically fix disposal routing, but I'm not done here yet

* Remove disposals reliance on implicit direction sensing entirely.
This commit is contained in:
20kdc
2021-10-29 09:07:32 +01:00
committed by GitHub
parent 01d62baa64
commit 7cdb9dcf86
8 changed files with 64 additions and 55 deletions

View File

@@ -4,11 +4,13 @@ using System.Linq;
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Disposal.Tube.Components;
using Content.Server.Disposal.Tube;
using Content.Server.Items;
using Content.Shared.Atmos;
using Content.Shared.Body.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -41,10 +43,17 @@ namespace Content.Server.Disposal.Unit.Components
public IDisposalTubeComponent? PreviousTube { get; set; }
[ViewVariables]
public IDisposalTubeComponent? CurrentTube { get; private set; }
public Direction PreviousDirection { get; private set; } = Direction.Invalid;
[ViewVariables]
public IDisposalTubeComponent? NextTube { get; set; }
public Direction PreviousDirectionFrom => (PreviousDirection == Direction.Invalid) ? Direction.Invalid : PreviousDirection.GetOpposite();
[ViewVariables]
public IDisposalTubeComponent? CurrentTube { get; private set; }
// CurrentDirection is not null when CurrentTube isn't null.
[ViewVariables]
public Direction CurrentDirection { get; private set; } = Direction.Invalid;
/// <summary>
/// A list of tags attached to the content, used for sorting
@@ -100,11 +109,12 @@ namespace Content.Server.Disposal.Unit.Components
if (CurrentTube != null)
{
PreviousTube = CurrentTube;
PreviousDirection = CurrentDirection;
}
Owner.Transform.Coordinates = tube.Owner.Transform.Coordinates;
CurrentTube = tube;
NextTube = tube.NextTube(this);
CurrentDirection = tube.NextDirection(this);
StartingTime = 0.1f;
TimeLeft = 0.1f;
}
@@ -115,8 +125,9 @@ namespace Content.Server.Disposal.Unit.Components
return;
PreviousTube = null;
PreviousDirection = Direction.Invalid;
CurrentTube = null;
NextTube = null;
CurrentDirection = Direction.Invalid;
StartingTime = 0;
TimeLeft = 0;
@@ -159,7 +170,7 @@ namespace Content.Server.Disposal.Unit.Components
TimeLeft -= time;
frameTime -= time;
if (CurrentTube == null)
if (CurrentTube == null || CurrentTube.Deleted)
{
ExitDisposals();
break;
@@ -168,16 +179,17 @@ namespace Content.Server.Disposal.Unit.Components
if (TimeLeft > 0)
{
var progress = 1 - TimeLeft / StartingTime;
var origin = CurrentTube.Owner.Transform.WorldPosition;
var destination = CurrentTube.NextDirection(this).ToVec();
var origin = CurrentTube.Owner.Transform.Coordinates;
var destination = CurrentDirection.ToVec();
var newPosition = destination * progress;
Owner.Transform.WorldPosition = origin + newPosition;
Owner.Transform.Coordinates = origin.Offset(newPosition);
continue;
}
if (NextTube == null || !CurrentTube.TransferTo(this, NextTube))
var nextTube = EntitySystem.Get<DisposalTubeSystem>().NextTubeFor(CurrentTube.Owner.Uid, CurrentDirection);
if (nextTube == null || nextTube.Deleted || !CurrentTube.TransferTo(this, nextTube))
{
CurrentTube.Remove(this);
break;