Make disposal units also flush air (#2686)
* Make disposal units also flush air * Make disposals use tile.AssumeAir instead of tile.Air.Merge Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -9,13 +12,14 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Disposal
|
||||
{
|
||||
// TODO: Add gas
|
||||
[RegisterComponent]
|
||||
public class DisposalHolderComponent : Component
|
||||
public class DisposalHolderComponent : Component, IGasMixtureHolder
|
||||
{
|
||||
public override string Name => "DisposalHolder";
|
||||
|
||||
@@ -49,6 +53,28 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
[ViewVariables]
|
||||
public HashSet<string> Tags { get; set; } = new();
|
||||
|
||||
[ViewVariables] public GasMixture Air { get; set; } = default!;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, x => x.Air, "air", new GasMixture(Atmospherics.CellVolume));
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_contents = ContainerManagerComponent.Ensure<Container>(nameof(DisposalHolderComponent), Owner);
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
base.OnRemove();
|
||||
ExitDisposals();
|
||||
}
|
||||
|
||||
private bool CanInsert(IEntity entity)
|
||||
{
|
||||
if (!_contents.CanInsert(entity))
|
||||
@@ -118,6 +144,13 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos) &&
|
||||
tileAtmos.Air != null)
|
||||
{
|
||||
tileAtmos.AssumeAir(Air);
|
||||
Air.Clear();
|
||||
}
|
||||
|
||||
Owner.Delete();
|
||||
}
|
||||
|
||||
@@ -159,18 +192,5 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
base.OnRemove();
|
||||
ExitDisposals();
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_contents = ContainerManagerComponent.Ensure<Container>(nameof(DisposalHolderComponent), Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user