Fix disposals error when sending something to space (#7626)
This commit is contained in:
@@ -1,16 +1,11 @@
|
||||
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.Disposal.Unit.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
@@ -21,6 +16,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly DisposalUnitSystem _disposalUnitSystem = default!;
|
||||
[Dependency] private readonly DisposalTubeSystem _disposalTubeSystem = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
|
||||
public void ExitDisposals(EntityUid uid, DisposalHolderComponent? holder = null, TransformComponent? holderTransform = null)
|
||||
{
|
||||
@@ -36,40 +32,37 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
// Check for a disposal unit to throw them into and then eject them from it.
|
||||
// *This ejection also makes the target not collide with the unit.*
|
||||
// *This is on purpose.*
|
||||
var grid = _mapManager.GetGrid(holderTransform.GridID);
|
||||
var gridTileContents = grid.GetLocal(holderTransform.Coordinates);
|
||||
|
||||
DisposalUnitComponent? duc = null;
|
||||
foreach (var contentUid in gridTileContents)
|
||||
if (_mapManager.TryGetGrid(holderTransform.GridID, out var grid))
|
||||
{
|
||||
if (EntityManager.TryGetComponent(contentUid, out duc))
|
||||
break;
|
||||
foreach (var contentUid in grid.GetLocal(holderTransform.Coordinates))
|
||||
{
|
||||
if (EntityManager.TryGetComponent(contentUid, out duc))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var entity in holder.Container.ContainedEntities.ToArray())
|
||||
{
|
||||
if (HasComp<BeingDisposedComponent>(entity))
|
||||
RemComp <BeingDisposedComponent>(entity);
|
||||
RemComp<BeingDisposedComponent>(entity);
|
||||
|
||||
if (EntityManager.TryGetComponent(entity, out IPhysBody? physics))
|
||||
{
|
||||
physics.CanCollide = true;
|
||||
}
|
||||
|
||||
holder.Container.ForceRemove(entity);
|
||||
var meta = MetaData(entity);
|
||||
holder.Container.ForceRemove(entity, EntityManager, meta);
|
||||
|
||||
if (EntityManager.GetComponent<TransformComponent>(entity).Parent == holderTransform)
|
||||
{
|
||||
if (duc != null)
|
||||
{
|
||||
// Insert into disposal unit
|
||||
EntityManager.GetComponent<TransformComponent>(entity).Coordinates = new EntityCoordinates((duc).Owner, Vector2.Zero);
|
||||
duc.Container.Insert(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityManager.GetComponent<TransformComponent>(entity).AttachParentToContainerOrGrid();
|
||||
}
|
||||
}
|
||||
var xform = Transform(entity);
|
||||
if (xform.ParentUid != uid)
|
||||
continue;
|
||||
|
||||
if (duc != null)
|
||||
duc.Container.Insert(entity, EntityManager, xform, meta: meta);
|
||||
else
|
||||
xform.AttachParentToContainerOrGrid(EntityManager);
|
||||
}
|
||||
|
||||
if (duc != null)
|
||||
@@ -77,11 +70,9 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
_disposalUnitSystem.TryEjectContents(duc);
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (atmosphereSystem.GetTileMixture(holderTransform.Coordinates, true) is {} environment)
|
||||
if (_atmosphereSystem.GetTileMixture(holderTransform.Coordinates, true) is {} environment)
|
||||
{
|
||||
atmosphereSystem.Merge(environment, holder.Air);
|
||||
_atmosphereSystem.Merge(environment, holder.Air);
|
||||
holder.Air.Clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user