Suffocation alerts for nitrogen breathers (#24373)

* Respiratorsystem namespace

* WIP gas alert update, does not work

* Finally
This commit is contained in:
Errant
2024-01-23 21:17:40 +01:00
committed by GitHub
parent 88deadead5
commit 2737c80169
12 changed files with 203 additions and 167 deletions

View File

@@ -1,5 +1,6 @@
using Content.Server.Atmos; using Content.Server.Atmos;
using Content.Server.Body.Systems; using Content.Server.Body.Systems;
using Content.Shared.Alert;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
@@ -27,4 +28,10 @@ public sealed partial class LungComponent : Component
/// </summary> /// </summary>
[DataField] [DataField]
public Entity<SolutionComponent>? Solution = null; public Entity<SolutionComponent>? Solution = null;
/// <summary>
/// The type of gas this lung needs. Used only for the breathing alerts, not actual metabolism.
/// </summary>
[DataField]
public AlertType Alert = AlertType.LowOxygen;
} }

View File

@@ -13,8 +13,8 @@ using Content.Shared.Mobs.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Server.Body.Systems namespace Content.Server.Body.Systems;
{
[UsedImplicitly] [UsedImplicitly]
public sealed class RespiratorSystem : EntitySystem public sealed class RespiratorSystem : EntitySystem
{ {
@@ -161,7 +161,12 @@ namespace Content.Server.Body.Systems
if (respirator.SuffocationCycles >= respirator.SuffocationCycleThreshold) if (respirator.SuffocationCycles >= respirator.SuffocationCycleThreshold)
{ {
_alertsSystem.ShowAlert(uid, AlertType.LowOxygen); // TODO: This is not going work with multiple different lungs, if that ever becomes a possibility
var organs = _bodySystem.GetBodyOrganComponents<LungComponent>(uid);
foreach (var (comp, _) in organs)
{
_alertsSystem.ShowAlert(uid, comp.Alert);
}
} }
_damageableSys.TryChangeDamage(uid, respirator.Damage, false, false); _damageableSys.TryChangeDamage(uid, respirator.Damage, false, false);
@@ -172,7 +177,12 @@ namespace Content.Server.Body.Systems
if (respirator.SuffocationCycles >= 2) if (respirator.SuffocationCycles >= 2)
_adminLogger.Add(LogType.Asphyxiation, $"{ToPrettyString(uid):entity} stopped suffocating"); _adminLogger.Add(LogType.Asphyxiation, $"{ToPrettyString(uid):entity} stopped suffocating");
_alertsSystem.ClearAlert(uid, AlertType.LowOxygen); // TODO: This is not going work with multiple different lungs, if that ever becomes a possibility
var organs = _bodySystem.GetBodyOrganComponents<LungComponent>(uid);
foreach (var (comp, _) in organs)
{
_alertsSystem.ClearAlert(uid, comp.Alert);
}
_damageableSys.TryChangeDamage(uid, respirator.DamageRecovery); _damageableSys.TryChangeDamage(uid, respirator.DamageRecovery);
} }
@@ -210,7 +220,6 @@ namespace Content.Server.Body.Systems
component.AccumulatedFrametime = component.CycleDelay; component.AccumulatedFrametime = component.CycleDelay;
} }
} }
}
public sealed class InhaleLocationEvent : EntityEventArgs public sealed class InhaleLocationEvent : EntityEventArgs
{ {

View File

@@ -1,4 +1,5 @@
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Systems;
using Content.Server.Disposal.Unit.Components; using Content.Server.Disposal.Unit.Components;
namespace Content.Server.Disposal.Unit.EntitySystems; namespace Content.Server.Disposal.Unit.EntitySystems;

View File

@@ -16,6 +16,7 @@ using Content.Shared.Popups;
using Content.Shared.Tools.Components; using Content.Shared.Tools.Components;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Content.Shared.Wires; using Content.Shared.Wires;
using Content.Server.Body.Systems;
using Robust.Server.Containers; using Robust.Server.Containers;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Containers; using Robust.Shared.Containers;

View File

@@ -1,4 +1,5 @@
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Systems;
using Content.Server.Medical.Components; using Content.Server.Medical.Components;
using Content.Shared.Medical.Cryogenics; using Content.Shared.Medical.Cryogenics;

View File

@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Systems;
using Content.Server.Construction; using Content.Server.Construction;
using Content.Server.Construction.Components; using Content.Server.Construction.Components;
using Content.Server.Storage.Components; using Content.Server.Storage.Components;

View File

@@ -9,6 +9,7 @@ namespace Content.Shared.Alert
{ {
Error, Error,
LowOxygen, LowOxygen,
LowNitrogen,
LowPressure, LowPressure,
HighPressure, HighPressure,
Fire, Fire,

View File

@@ -1,6 +1,9 @@
alerts-low-oxygen-name = [color=red]Low Oxygen[/color] alerts-low-oxygen-name = [color=red]Low Oxygen[/color]
alerts-low-oxygen-desc = There is [color=red]not enough oxygen[/color] in the air you are breathing. Put on [color=green]internals[/color]. alerts-low-oxygen-desc = There is [color=red]not enough oxygen[/color] in the air you are breathing. Put on [color=green]internals[/color].
alerts-low-nitrogen-name = [color=red]Low Nitrogen[/color]
alerts-low-nitrogen-desc = There is [color=red]not enough nitrogen[/color] in the air you are breathing. Put on [color=green]internals[/color].
alerts-high-toxin-name = [color=red]High Toxin Level[/color] alerts-high-toxin-name = [color=red]High Toxin Level[/color]
alerts-high-toxin-desc = There are [color=red]too many toxins[/color] in the air you are breathing. Put on [color=green]internals[/color] or get away. alerts-high-toxin-desc = There are [color=red]too many toxins[/color] in the air you are breathing. Put on [color=green]internals[/color] or get away.

View File

@@ -34,6 +34,15 @@
name: alerts-low-oxygen-name name: alerts-low-oxygen-name
description: alerts-low-oxygen-desc description: alerts-low-oxygen-desc
- type: alert
id: LowNitrogen
category: Breathing
icons:
- sprite: /Textures/Interface/Alerts/breathing.rsi
state: not_enough_nitro
name: alerts-low-nitrogen-name
description: alerts-low-nitrogen-desc
- type: alert - type: alert
id: Toxins id: Toxins
category: Toxins category: Toxins

View File

@@ -37,6 +37,7 @@
- state: lung-l-slime - state: lung-l-slime
- state: lung-r-slime - state: lung-r-slime
- type: Lung - type: Lung
Alert: LowNitrogen
- type: Metabolizer - type: Metabolizer
removeEmpty: true removeEmpty: true
solutionOnBody: false solutionOnBody: false

View File

@@ -43,6 +43,7 @@
- state: lung-l-slime - state: lung-l-slime
- state: lung-r-slime - state: lung-r-slime
- type: Lung - type: Lung
alert: LowNitrogen
- type: Metabolizer - type: Metabolizer
removeEmpty: true removeEmpty: true
solutionOnBody: false solutionOnBody: false

View File

@@ -5,4 +5,5 @@
components: components:
- type: Metabolizer - type: Metabolizer
metabolizerTypes: [ Vox ] metabolizerTypes: [ Vox ]
- type: Lung
alert: LowNitrogen