Disposals air + new atmos expose event (#6798)
Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -24,4 +24,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
GasMixture = mixture;
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public struct AtmosExposedGetAirEvent
|
||||
{
|
||||
public GasMixture? Gas;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,15 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
foreach (var (exposed, transform) in EntityManager.EntityQuery<AtmosExposedComponent, TransformComponent>())
|
||||
{
|
||||
var tile = GetTileMixture(transform.Coordinates);
|
||||
if (tile == null) continue;
|
||||
var updateEvent = new AtmosExposedUpdateEvent(transform.Coordinates, tile);
|
||||
// Used for things like disposals/cryo to change which air people are exposed to.
|
||||
var airEvent = new AtmosExposedGetAirEvent();
|
||||
RaiseLocalEvent(exposed.Owner, ref airEvent, false);
|
||||
|
||||
airEvent.Gas ??= GetTileMixture(transform.Coordinates);
|
||||
if (airEvent.Gas == null)
|
||||
continue;
|
||||
|
||||
var updateEvent = new AtmosExposedUpdateEvent(transform.Coordinates, airEvent.Gas);
|
||||
RaiseLocalEvent(exposed.Owner, ref updateEvent);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Content.Server.Disposal.Unit.Components;
|
||||
|
||||
/// <summary>
|
||||
/// A component added to entities that are currently in disposals.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class BeingDisposedComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public EntityUid Holder;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("air")]
|
||||
public GasMixture Air { get; set; } = new GasMixture(Atmospherics.CellVolume);
|
||||
public GasMixture Air { get; set; } = new (70);
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems;
|
||||
|
||||
public sealed class BeingDisposedSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BeingDisposedComponent, InhaleLocationEvent>(OnInhaleLocation);
|
||||
SubscribeLocalEvent<BeingDisposedComponent, ExhaleLocationEvent>(OnExhaleLocation);
|
||||
SubscribeLocalEvent<BeingDisposedComponent, AtmosExposedGetAirEvent>(OnGetAir);
|
||||
}
|
||||
|
||||
private void OnGetAir(EntityUid uid, BeingDisposedComponent component, ref AtmosExposedGetAirEvent args)
|
||||
{
|
||||
if (TryComp<DisposalHolderComponent>(component.Holder, out var holder))
|
||||
{
|
||||
args.Gas = holder.Air;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInhaleLocation(EntityUid uid, BeingDisposedComponent component, InhaleLocationEvent args)
|
||||
{
|
||||
if (TryComp<DisposalHolderComponent>(component.Holder, out var holder))
|
||||
{
|
||||
args.Gas = holder.Air;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExhaleLocation(EntityUid uid, BeingDisposedComponent component, ExhaleLocationEvent args)
|
||||
{
|
||||
if (TryComp<DisposalHolderComponent>(component.Holder, out var holder))
|
||||
{
|
||||
args.Gas = holder.Air;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,9 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
foreach (var entity in holder.Container.ContainedEntities.ToArray())
|
||||
{
|
||||
if (HasComp<BeingDisposedComponent>(entity))
|
||||
RemComp <BeingDisposedComponent>(entity);
|
||||
|
||||
if (EntityManager.TryGetComponent(entity, out IPhysBody? physics))
|
||||
{
|
||||
physics.CanCollide = true;
|
||||
@@ -101,6 +104,12 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var ent in holder.Container.ContainedEntities)
|
||||
{
|
||||
var comp = EnsureComp<BeingDisposedComponent>(ent);
|
||||
comp.Holder = holder.Owner;
|
||||
}
|
||||
|
||||
// Insert into next tube
|
||||
holderTransform.Coordinates = new EntityCoordinates(toUid, Vector2.Zero);
|
||||
if (!to.Contents.Insert(holder.Owner))
|
||||
|
||||
@@ -486,7 +486,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
if (_atmosSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates, true) is {Temperature: > 0} environment)
|
||||
{
|
||||
var transferMoles = 0.1f * (0.05f * Atmospherics.OneAtmosphere * 1.01f - air.Pressure) * air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
var transferMoles = 0.1f * (0.25f * Atmospherics.OneAtmosphere * 1.01f - air.Pressure) * air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
|
||||
component.Air = environment.Remove(transferMoles);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user