Disposal trunks now eject incoming entities (#1942)
* Implement disposal trunk eject on incomming entities * Move variable declaration into if block Co-authored-by: Julian Giebel <j.giebel@netrocks.info>
This commit is contained in:
parent
c09c9176ef
commit
3758eb1b60
|
|
@ -1,7 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Disposal
|
||||
{
|
||||
|
|
@ -9,6 +13,8 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||
[ComponentReference(typeof(IDisposalTubeComponent))]
|
||||
public class DisposalEntryComponent : DisposalTubeComponent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private const string HolderPrototypeId = "DisposalHolder";
|
||||
|
||||
public override string Name => "DisposalEntry";
|
||||
|
|
@ -43,8 +49,19 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||
return new[] {Owner.Transform.LocalRotation.GetDir()};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ejects contents when they come from the same direction the entry is facing.
|
||||
/// </summary>
|
||||
public override Direction NextDirection(DisposalHolderComponent holder)
|
||||
{
|
||||
if (holder.PreviousTube != null && DirectionTo(holder.PreviousTube) == ConnectableDirections()[0])
|
||||
{
|
||||
var invalidDirections = new Direction[] { ConnectableDirections()[0], Direction.Invalid };
|
||||
var directions = System.Enum.GetValues(typeof(Direction))
|
||||
.Cast<Direction>().Except(invalidDirections).ToList();
|
||||
return _random.Pick<Direction>(directions);
|
||||
}
|
||||
|
||||
return ConnectableDirections()[0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue