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
This commit is contained in:
20kdc
2021-11-23 23:38:46 +00:00
committed by GitHub
parent 0e98c1c524
commit eb18f7bc1c
5 changed files with 182 additions and 162 deletions

View File

@@ -1,7 +1,9 @@
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;
@@ -13,8 +15,6 @@ namespace Content.Server.Disposal.Tube.Components
[ComponentReference(typeof(IDisposalTubeComponent))]
public class DisposalEntryComponent : DisposalTubeComponent
{
[Dependency] private readonly IRobustRandom _random = default!;
private const string HolderPrototypeId = "DisposalHolder";
public override string Name => "DisposalEntry";
@@ -32,19 +32,7 @@ namespace Content.Server.Disposal.Tube.Components
EntitySystem.Get<AtmosphereSystem>().Merge(holderComponent.Air, from.Air);
from.Air.Clear();
return TryInsert(holderComponent);
}
public bool TryInsert(DisposalHolderComponent holder)
{
if (!Contents.Insert(holder.Owner))
{
return false;
}
holder.EnterTube(this);
return true;
return EntitySystem.Get<DisposableSystem>().EnterTube(holderComponent.OwnerUid, OwnerUid, holderComponent, null, this);
}
protected override Direction[] ConnectableDirections()
@@ -57,12 +45,9 @@ namespace Content.Server.Disposal.Tube.Components
/// </summary>
public override Direction NextDirection(DisposalHolderComponent holder)
{
if (holder.PreviousDirectionFrom != Direction.Invalid && holder.PreviousDirectionFrom == ConnectableDirections()[0])
if (holder.PreviousDirectionFrom != Direction.Invalid)
{
var invalidDirections = new[] { ConnectableDirections()[0], Direction.Invalid };
var directions = Enum.GetValues(typeof(Direction))
.Cast<Direction>().Except(invalidDirections).ToList();
return _random.Pick(directions);
return Direction.Invalid;
}
return ConnectableDirections()[0];

View File

@@ -2,6 +2,7 @@ using System;
using System.Linq;
using Content.Server.Construction.Components;
using Content.Server.Disposal.Unit.Components;
using Content.Server.Disposal.Unit.EntitySystems;
using Content.Shared.Acts;
using Content.Shared.Disposal.Components;
using Content.Shared.Popups;
@@ -48,34 +49,6 @@ namespace Content.Server.Disposal.Tube.Components
public abstract Direction NextDirection(DisposalHolderComponent holder);
public virtual Vector2 ExitVector(DisposalHolderComponent holder)
{
return NextDirection(holder).ToVec();
}
public bool Remove(DisposalHolderComponent holder)
{
var removed = Contents.Remove(holder.Owner);
holder.ExitDisposals();
return removed;
}
public bool TransferTo(DisposalHolderComponent holder, IDisposalTubeComponent to)
{
var position = holder.Owner.Transform.LocalPosition;
if (!to.Contents.Insert(holder.Owner))
{
return false;
}
holder.Owner.Transform.LocalPosition = position;
Contents.Remove(holder.Owner);
holder.EnterTube(to);
return true;
}
// TODO: Make disposal pipes extend the grid
private void Connect()
{
@@ -123,7 +96,7 @@ namespace Content.Server.Disposal.Tube.Components
continue;
}
holder.ExitDisposals();
EntitySystem.Get<DisposableSystem>().ExitDisposals(holder.OwnerUid);
}
}

View File

@@ -10,9 +10,6 @@ namespace Content.Server.Disposal.Tube.Components
Container Contents { get; }
Direction NextDirection(DisposalHolderComponent holder);
Vector2 ExitVector(DisposalHolderComponent holder);
bool Remove(DisposalHolderComponent holder);
bool TransferTo(DisposalHolderComponent holder, IDisposalTubeComponent to);
bool CanConnect(Direction direction, IDisposalTubeComponent with);
void PopupDirections(IEntity entity);
}