Add being able to breathe healing asphyxiation damage (#3194)

* Add healing suffocation damage when breathing

* Fix suffocation doing airloss instead of asphyxiation
This commit is contained in:
DrSmugleaf
2021-02-14 15:42:51 +01:00
committed by GitHub
parent ad611755dc
commit 54f48aa6a9

View File

@@ -42,6 +42,8 @@ namespace Content.Server.GameObjects.Components.Metabolism
[ViewVariables(VVAccess.ReadWrite)] private int _suffocationDamage; [ViewVariables(VVAccess.ReadWrite)] private int _suffocationDamage;
[ViewVariables(VVAccess.ReadWrite)] private int _suffocationDamageRecovery;
[ViewVariables] public Dictionary<Gas, float> NeedsGases { get; set; } = new(); [ViewVariables] public Dictionary<Gas, float> NeedsGases { get; set; } = new();
[ViewVariables] public Dictionary<Gas, float> ProducesGases { get; set; } = new(); [ViewVariables] public Dictionary<Gas, float> ProducesGases { get; set; } = new();
@@ -107,6 +109,7 @@ namespace Content.Server.GameObjects.Components.Metabolism
serializer.DataField(this, b => b.ThermalRegulationTemperatureThreshold, serializer.DataField(this, b => b.ThermalRegulationTemperatureThreshold,
"thermalRegulationTemperatureThreshold", 0); "thermalRegulationTemperatureThreshold", 0);
serializer.DataField(ref _suffocationDamage, "suffocationDamage", 1); serializer.DataField(ref _suffocationDamage, "suffocationDamage", 1);
serializer.DataField(ref _suffocationDamageRecovery, "suffocationDamageRecovery", 1);
} }
private Dictionary<Gas, float> NeedsAndDeficit(float frameTime) private Dictionary<Gas, float> NeedsAndDeficit(float frameTime)
@@ -399,13 +402,18 @@ namespace Content.Server.GameObjects.Components.Metabolism
return; return;
} }
damageable.ChangeDamage(DamageClass.Airloss, _suffocationDamage, false); damageable.ChangeDamage(DamageType.Asphyxiation, _suffocationDamage, false);
} }
private void StopSuffocation() private void StopSuffocation()
{ {
Suffocating = false; Suffocating = false;
if (Owner.TryGetComponent(out IDamageableComponent? damageable))
{
damageable.ChangeDamage(DamageType.Asphyxiation, -_suffocationDamageRecovery, false);
}
if (Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent)) if (Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent))
{ {
alertsComponent.ClearAlert(AlertType.LowOxygen); alertsComponent.ClearAlert(AlertType.LowOxygen);