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