From 54f48aa6a9a8fc4581a89cba0fde32a9b54449f1 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 14 Feb 2021 15:42:51 +0100 Subject: [PATCH] Add being able to breathe healing asphyxiation damage (#3194) * Add healing suffocation damage when breathing * Fix suffocation doing airloss instead of asphyxiation --- .../Components/Metabolism/MetabolismComponent.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Metabolism/MetabolismComponent.cs b/Content.Server/GameObjects/Components/Metabolism/MetabolismComponent.cs index 9e4fc39497..d7a292b0cb 100644 --- a/Content.Server/GameObjects/Components/Metabolism/MetabolismComponent.cs +++ b/Content.Server/GameObjects/Components/Metabolism/MetabolismComponent.cs @@ -42,6 +42,8 @@ namespace Content.Server.GameObjects.Components.Metabolism [ViewVariables(VVAccess.ReadWrite)] private int _suffocationDamage; + [ViewVariables(VVAccess.ReadWrite)] private int _suffocationDamageRecovery; + [ViewVariables] public Dictionary NeedsGases { get; set; } = new(); [ViewVariables] public Dictionary ProducesGases { get; set; } = new(); @@ -107,6 +109,7 @@ namespace Content.Server.GameObjects.Components.Metabolism serializer.DataField(this, b => b.ThermalRegulationTemperatureThreshold, "thermalRegulationTemperatureThreshold", 0); serializer.DataField(ref _suffocationDamage, "suffocationDamage", 1); + serializer.DataField(ref _suffocationDamageRecovery, "suffocationDamageRecovery", 1); } private Dictionary NeedsAndDeficit(float frameTime) @@ -399,13 +402,18 @@ namespace Content.Server.GameObjects.Components.Metabolism return; } - damageable.ChangeDamage(DamageClass.Airloss, _suffocationDamage, false); + damageable.ChangeDamage(DamageType.Asphyxiation, _suffocationDamage, false); } private void StopSuffocation() { Suffocating = false; + if (Owner.TryGetComponent(out IDamageableComponent? damageable)) + { + damageable.ChangeDamage(DamageType.Asphyxiation, -_suffocationDamageRecovery, false); + } + if (Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent)) { alertsComponent.ClearAlert(AlertType.LowOxygen);