Files
tbd-station-14/Content.Server/Disposal/Tube/Components/DisposalTransitComponent.cs
20kdc 7cdb9dcf86 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.
2021-10-29 19:07:32 +11:00

39 lines
1.2 KiB
C#

using System;
using Content.Server.Disposal.Unit.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Content.Server.Disposal.Tube.Components
{
// TODO: Different types of tubes eject in random direction with no exit point
[RegisterComponent]
[ComponentReference(typeof(IDisposalTubeComponent))]
public class DisposalTransitComponent : DisposalTubeComponent
{
public override string Name => "DisposalTransit";
protected override Direction[] ConnectableDirections()
{
var rotation = Owner.Transform.LocalRotation;
var opposite = new Angle(rotation.Theta + Math.PI);
return new[] {rotation.GetDir(), opposite.GetDir()};
}
public override Direction NextDirection(DisposalHolderComponent holder)
{
var directions = ConnectableDirections();
var previousDF = holder.PreviousDirectionFrom;
var forward = directions[0];
if (previousDF == Direction.Invalid)
{
return forward;
}
var backward = directions[1];
return previousDF == forward ? backward : forward;
}
}
}