Files
crystall-punk-14/Content.Server/Disposal/Tube/Components/DisposalEntryComponent.cs
20kdc eb18f7bc1c Sending a mob out of a disposals unit shouldn't push them into a wall anymore (#5411)
* Sending a mob out of a disposals unit shouldn't push them into a wall anymore.

* Something something resolves vs. OnRemove fighting it out

* Disposals yeet reduction: Address reviews and other oddities
2021-11-23 16:38:46 -07:00

57 lines
1.9 KiB
C#

using System;
using System.Linq;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Disposal.Tube;
using Content.Server.Disposal.Unit.Components;
using Content.Server.Disposal.Unit.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Random;
namespace Content.Server.Disposal.Tube.Components
{
[RegisterComponent]
[ComponentReference(typeof(IDisposalTubeComponent))]
public class DisposalEntryComponent : DisposalTubeComponent
{
private const string HolderPrototypeId = "DisposalHolder";
public override string Name => "DisposalEntry";
public bool TryInsert(DisposalUnitComponent from)
{
var holder = Owner.EntityManager.SpawnEntity(HolderPrototypeId, Owner.Transform.MapPosition);
var holderComponent = holder.GetComponent<DisposalHolderComponent>();
foreach (var entity in from.ContainedEntities.ToArray())
{
holderComponent.TryInsert(entity);
}
EntitySystem.Get<AtmosphereSystem>().Merge(holderComponent.Air, from.Air);
from.Air.Clear();
return EntitySystem.Get<DisposableSystem>().EnterTube(holderComponent.OwnerUid, OwnerUid, holderComponent, null, this);
}
protected override Direction[] ConnectableDirections()
{
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.PreviousDirectionFrom != Direction.Invalid)
{
return Direction.Invalid;
}
return ConnectableDirections()[0];
}
}
}